This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typedef const bool (^ __strong object_block)(const bool); | |
| object_block object_blk = ^ bool (const bool b) { | |
| printf("object_blk state == %s\n", (b) ? "TRUE" : "FALSE"); | |
| return b; | |
| }; | |
| object_block object_blk_2 = ^ bool (const bool b) { | |
| printf("object_blk_2 state == %s\n", (b) ? "TRUE" : "FALSE"); | |
| return b; | |
| }; | |
| object_block object_blk_3 = ^ bool (const bool b) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typedef const void (^ const __strong object_block)(const bool); | |
| object_block object_blk = ^ (const bool b) { | |
| printf("object_blk state == %s\n", (b) ? "TRUE" : "FALSE"); | |
| }; | |
| object_block object_blk_2 = ^ (const bool b) { | |
| printf("object_blk_2 state == %s\n", (b) ? "TRUE" : "FALSE"); | |
| }; | |
| object_block object_blk_3 = ^ (const bool b) { | |
| printf("object_blk_3 state == %s\n", (b) ? "TRUE" : "FALSE"); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static void (^(^(^(^array_pointer_test)(const unsigned int))(CFTypeRef(^)(void)))(void(^)(CFTypeRef)))(CFTypeRef(^)(CFTypeRef)) = ^ (unsigned int object_count) { | |
| typedef CFTypeRef objects[object_count]; | |
| typeof(objects) objects_ptr[object_count]; | |
| __block unsigned long (^recursive_block)(unsigned long); | |
| (recursive_block = ^ unsigned long (unsigned long index) { | |
| printf("index == %lu\n", index); | |
| return (unsigned long)(index ^ 0UL) && (unsigned long)(recursive_block)(~-index); | |
| })(object_count); | |
| return ^ (CFTypeRef * objects_t) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __block unsigned long (^recursive_block)(unsigned long); | |
| (recursive_block = ^ unsigned long (unsigned long index) { | |
| printf("index == %lu\n", index); | |
| return (unsigned long)(index ^ (unsigned long)(recursive_block)(~-index)); | |
| })(10); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static int counter = 0; | |
| // ... | |
| id (^retainable_object_)(id(^)(void)) = ^ id (id(^object)(void)) { | |
| return ^{ | |
| return object(); | |
| }; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import "ViewController.h" | |
| @import AVFoundation; | |
| @interface ViewController () { | |
| AVAudioEngine * engine; | |
| AVAudioSourceNode * whiteNoiseGenerator; | |
| } | |
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static double (^(^(^random_generator)(double(^(*))(double)))(double(^(*))(double)))(void) = ^ (double(^(*distributor))(double)) { | |
| srand48((unsigned int)time(0)); | |
| return ^ (double(^(*number))(double)) { | |
| static double random; | |
| return ^ double { | |
| return (*number)((*distributor)((random = drand48()))); | |
| }; | |
| }; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Returns a generic pointer to an object of any type | |
| const void * (^object_t)(const unsigned long) = ^ const void * (const unsigned long index) { | |
| UIButton * button; | |
| [button = [UIButton new] setTag:index]; | |
| printf("\nbutton == %p\n\n", &button); | |
| return (const id *)CFBridgingRetain(button); | |
| }; | |
| // Outer block retains a generic pointer reference to an object of any type for subsequent calls to inner block | |
| // Inner block returns the object referenced by the generic pointer retained by outer block |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const float (^(^blk)(float))(void) = ^ (float f) { | |
| return ^ (float f) { | |
| return ^ float { | |
| return f; | |
| }; | |
| }(f); | |
| }; | |
| const float(^blk_param)(void) = blk(1.0); | |
| printf("blk_param() == %f\n", blk_param()); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)recursive_block { | |
| unsigned long (^recursive_block)(int); | |
| unsigned long (^ const (* restrict recursive_block_t))(int) = &recursive_block; | |
| __block unsigned long iterations = 30; | |
| iterations = ~(1 << (iterations + 1)); | |
| __block unsigned long iteration; | |
| recursive_block = ^ (void(^print_block)(int, int)) { | |
| return ^ unsigned long (int count) { |