Skip to content

Instantly share code, notes, and snippets.

@tomaszj
Created July 4, 2012 14:39
Show Gist options
  • Save tomaszj/3047703 to your computer and use it in GitHub Desktop.
Save tomaszj/3047703 to your computer and use it in GitHub Desktop.
Block example
// 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