Created
July 4, 2012 14:39
-
-
Save tomaszj/3047703 to your computer and use it in GitHub Desktop.
Block example
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
// In the project far, far away... | |
// .h | |
typedef void(^SuccessBlock)(); | |
typedef void(^FailureBlock)(NSString *errorMessage); | |
- (void)executeCommandWithSuccessBlock:(SuccessBlock)successBlock failureBlock:(FailureBlock)failureBlock; | |
// usage | |
[someCommand executeCommandWithSuccessBlock:^{ | |
NSLog(@"Well, well, splendid."); | |
} failureBlock:^(NSString *errorMessage){ | |
NSLog(@"Uh oh!"); | |
NSLog(@"By the way, the error message is %@", errorMessage); | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment