Umair Suraj
Umair Suraj

Reputation: 490

predicateWithFormat:argumentArray: Using all items in NSArray

- (void)filterViaCategories:(NSArray *)array   {
        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(todo_category_id == %@)" argumentArray:array]; 
}

but when I have used:

po predicate

Result is:

todo_category_id == 41123..

It just using 41123 from zero index element of array

i want all categories from data base for all id present in array not the only object at index zero: (todo_category_id == 41123, 41234, 33455) etc.

How can I do this?

Upvotes: 0

Views: 311

Answers (1)

Wain
Wain

Reputation: 119041

Then you should not be using predicateWithFormat:argumentArray: and you need to change your format.

You want something like:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"todo_category_id IN %@", array]; 

Upvotes: 1

Related Questions