Reputation:
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];
Upvotes: 1
Views: 614
Reputation: 8170
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];
Upvotes: 4