I have a NSMutableArray, and I want to check if there is an object there with a certain property set to a specific value. For example, the array is filled with users, and I want to check if there is an object with variable user_id set to 67. Is there a way to do this with blocks or predicates or something without having to loop through the array?
This did the trick from the afore mentioned link!
NSArray *people = /* array of people objects */
NSPredicate *pred = [NSPredicate predicateWithFormat:@"Id = 1 AND Id != 2"];
NSArray *matches = [people filteredArrayUsingPredicate:pred];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.