Skip to content

Instantly share code, notes, and snippets.

@miguel12345
Created November 28, 2013 18:20
Show Gist options
  • Save miguel12345/7696253 to your computer and use it in GitHub Desktop.
Save miguel12345/7696253 to your computer and use it in GitHub Desktop.
Block
// Here's a method that takes a block
- (void)doMathWithBlock:(int (^)(int, int))mathBlock {
self.label.text = [NSString stringWithFormat:@"%d", mathBlock(3, 5)];
}
 
// Calling that method with a block
- (IBAction)buttonTapped:(id)sender {
[self doMathWithBlock:^(int a, int b) {
return a + b;
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment