Created
July 27, 2015 10:08
-
-
Save StarWars/0b4f4ef8a139dde250d3 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
-(void)enumerateObjectsUsingBlockzzz:(void(^)(id obj, NSUInteger idx, BOOL *stop))block; | |
-(void)enumerateObjectsUsingBlockzzz:(void (^)(id, NSUInteger, BOOL*))block { | |
BOOL stop = NO; | |
for (int i = 0; i < [self count]; i++) { | |
block(self[i],i,&stop); | |
if (stop) { | |
break; | |
} | |
} | |
} | |
NSArray *arr = @[@"1", @"2", @"3", @"4", @"5"]; | |
[arr enumerateObjectsUsingBlockzzz:^(id obj, NSUInteger idx, BOOL *stop) { | |
NSLog(@"%@ %lu ",obj, idx); | |
if ([obj isEqualToString:@"3"]) { | |
*stop = YES; | |
} | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment