문제

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];
도움이 되었습니까?

해결책

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];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top