user1107173
user1107173

Reputation: 10784

iOS: Core Data Fetch

Entity: Person

Attributes: firstName, lastName, Id

An example of an array that I get from the server:

[Bob,
 Bill,
 John,
 Peter,
 Sam,
 Kyle,
 Jimmy,
 Ryan,
 Willy]

The array size of the array being returned will vary.

I want to pass all the objects from the array to some method and get back all the objects from Core Data that has a firstName matching with all the objects (names) in the array.

I'm thinking using compound predicates to accomplish this. But I'm not sure what the best practice is to get all the objects back with one fetch? Code example would be nice.

Upvotes: 0

Views: 56

Answers (1)

quellish
quellish

Reputation: 21254

[NSPredicate predicateWithFormat:@"ANY SELF.firstName in %@", [NSSet setWithArray:firstNameArray]];

Upvotes: 1

Related Questions