Skip to content

Instantly share code, notes, and snippets.

@ziggear
Created February 25, 2014 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziggear/9206330 to your computer and use it in GitHub Desktop.
Save ziggear/9206330 to your computer and use it in GitHub Desktop.
using block and callback
//block declare:
typedef int (^startBlock)(int a, int b);
typedef int (^endBlock)();
- (void) runBlock:(startBlock)_startBlock end:(endBlock)_endBlock{
int a = _startBlock(1,2);
int b = _endBlock();
NSLog(@"start block result : %d", a);
NSLog(@"end block result : %d", b);
}
//run block:
[self runBlock:^int(int a, int b) {
NSLog(@"args from run-block : %d, %d ", a, b);
return 1;
} end:^int{
return 2;
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment