如果我只传递一个 itemId
,下面的谓词就可以工作,但我想知道如果我有多个 itemId
,我怎么才能让它工作呢?
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(%K == %@)", kItemId, itemId];
NSArray *filteredArray = [restaurantData.itemArray filteredArrayUsingPredicate:predicate];
最佳答案
您可以执行IN
查询:
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"(%K IN %@)", kItemId, yourArrayOfItemId];
关于ios - 一个 id 数组,用于通过 NSPredicate 过滤数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43690277/