Created
November 28, 2013 18:20
-
-
Save miguel12345/7696253 to your computer and use it in GitHub Desktop.
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
// 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