我有一个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,那当然是完美的。