Created
February 18, 2014 04:51
-
-
Save icodebuster/9064806 to your computer and use it in GitHub Desktop.
Using predicate to retrieve an index of an object in an NSArray.
This file contains 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
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self.id == %@", @"1"]; | |
NSUInteger index = [mainArray indexOfObjectPassingTest:^(id obj, NSUInteger idx, BOOL *stop) { | |
return [predicate evaluateWithObject:obj]; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment