How to determine if object with given property exists in nsarray / nsmutablearray

arrays, ios, nsarray, objective-c

Solution

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];

Problem

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?

Original source

Related problems