Revision: 60232
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 26, 2012 07:50 by kutyadog
Initial Code
//-----demonstrate how blocks hold their captured state NSDate *date = [NSDate date]; void (^now)(void) = ^ { NSLog(@"The date and time is %@", date); }; now(); sleep(5); date = [NSDate date]; now(); //-------------- int (^triple)(int) = ^(int number) { return number * 3; }; int result1 = triple(2); int (^multiply)(int, int) = ^(int x, int y) { return x * y; }; int result2 = multiply(2, 3); NSLog(@"result %i", result2); result2 = multiply(5, 3); NSLog(@"result %i", result2);
Initial URL
Initial Description
Examples of how Objective-c objects work
Initial Title
xcode Objective C - block examples
Initial Tags
Initial Language
Objective C