Last active
November 30, 2017 05:14
-
-
Save hmhmsh/1fdf43e08683af6614e5951e2fa03b44 to your computer and use it in GitHub Desktop.
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
// pattern1 | |
-(void)a { | |
[self closure:^BOOL(int a, int b){ | |
return a > b; | |
}]; | |
} | |
-(void)closure:(BOOL(^)(int, int))close { | |
NSLog(@"%@", close(4,2) == 1?@"YES" : @"NO"); | |
} | |
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
// pattern2 | |
typedef bool (^myFunc)(int, int); | |
-(void)b { | |
myFunc fun = ^BOOL(int a, int b) { | |
return a > b; | |
}; | |
[self closure:fun]; | |
} | |
-(void)closure:(myFunc)close { | |
NSLog(@"%@", close(4,2) == 1?@"YES" : @"NO"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment