Question

I have an Array, containing Objects of Order Item Class, and in each order item there is an Article object in it, that contains its details.

Now I want to get the Order items that have a specific name in article of individual order item. How should I write my NSPredicate?

What I am trying is something like:

   NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF.itemArticle.articleName CONTAINS[c] '%@'", searchString];
   NSArray *resultsArray = [allOrderItemArray filteredArrayUsingPredicate: predicate];
Was it helpful?

Solution

Try removig both the SELF. part and the single quotes for the place holder (and close the double quotes).

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"itemArticle.articleName CONTAINS[c] %@", searchString];
NSArray *resultsArray = [allOrderItemArray filteredArrayUsingPredicate: predicate];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top