Created
July 19, 2014 01:09
-
-
Save mako34/11d631754b8de24f9ff7 to your computer and use it in GitHub Desktop.
iOS completion 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
| //define before implementation | |
| typedef void(^myCompletion)(BOOL); | |
| //method todo after implementation | |
| -(void) myMethod:(myCompletion) compblock{ | |
| //do stuff | |
| for (int i = 0; i < 100; i++) { | |
| NSLog(@"i :: %d", i); | |
| } | |
| compblock(YES); | |
| } | |
| //caller of the method, knows when complete | |
| [self myMethod:^(BOOL finished) { | |
| if(finished){ | |
| NSLog(@"success"); | |
| } | |
| }]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment