casillas
casillas

Reputation: 16813

An array of id to filter an Array via NSPredicate

The following predicate works if I only pass a single itemId but I wonder what if I have multiple itemId s, how could I able to make it work ?

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(%K == %@)", kItemId, itemId];
NSArray *filteredArray = [restaurantData.itemArray filteredArrayUsingPredicate:predicate];

Upvotes: 0

Views: 414

Answers (1)

janusfidel
janusfidel

Reputation: 8106

You can do IN query:

NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"(%K IN %@)", kItemId, yourArrayOfItemId];

Upvotes: 1

Related Questions