Skip to content

Instantly share code, notes, and snippets.

@bklimt
Last active December 12, 2015 02:39
Show Gist options
  • Save bklimt/4700897 to your computer and use it in GitHub Desktop.
Save bklimt/4700897 to your computer and use it in GitHub Desktop.
Objective-C Blocks Example B
void exampleB_addBlockToArray(NSMutableArray *array) {
char b = 'B';
[array addObject:^{
printf("%c\n", b);
}];
}
void exampleB() {
NSMutableArray *array = [NSMutableArray array];
exampleB_addBlockToArray(array);
void (^block)() = [array objectAtIndex:0];
block();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment