【发布时间】:2012-01-24 17:27:34
【问题描述】:
我有一个 NSArray,我想使用 NSPredicate 过滤掉某些对象,我希望我可以使用 NOT IN,因为我看到我可以轻松地执行 IN。
所以我有我的数组:
self.categoriesList
然后我得到我想要删除的值:
NSArray *parentIDs = [self.cateoriesList valueForKeyPath:@"@distinctUnionOfObjects.ParentCategoryID"];
这为我提供了我不想显示的类别的 ParentCategoryID 列表,所以我想我可以使用 NSPredicate 来删除它们:
self.cateoriesList = [self.cateoriesList filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"CategoryID NOT IN %@",parentIDs]];
这失败了:
reason: 'Unable to parse the format string "CategoryID NOT IN %@"'
如果我只想使用 IN 当然可以完美运行。
【问题讨论】:
标签: ios objective-c nsarray nspredicate