Created
February 25, 2014 10:16
-
-
Save ziggear/9206330 to your computer and use it in GitHub Desktop.
using block and callback
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 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