NSPredicate使用RLMResults作为参数

我试图通过使用NSPredicate进行过滤来获得两组Realm数据(并且是不同的对象)之间的区别,但是有一个错误我无法理解。 我的代码:

RLMResults *topStories = [KFXTopStory allObjects]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NONE threadId = %@.topStoryId", topStories]; RLMResults *objectsToDelete = [KFXThread objectsWithPredicate:predicate]; 

错误:

 *** Terminating app due to uncaught exception 'Invalid predicate', reason: 'Predicate with ANY modifier must compare a KeyPath with RLMArray with a value' 

该查询似乎表明必须将键路径与值进行比较,而不是与另一个键路径进行比较。 这种类型的查询甚至可以与Realm一起使用吗? 它看起来应该是,所以我哪里错了? 这个或更好的解决方案的任何帮助都会很棒 – 谢谢!

编辑:

当然,在我发布之后,我得到了一些有用的东西。 但我还是想知道是否有更好的方法。 工作代码:

 RLMResults *topStories = [KFXTopStory allObjects]; NSMutableArray *topStoryIds = [[NSMutableArray alloc] initWithCapacity:100]; for (KFXTopStory *story in topStories) { [topStoryIds addObject:story.topStoryId]; } NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT (threadId IN %@)", topStoryIds]; RLMResults *objectsToDelete = [KFXThread objectsWithPredicate:predicate]; 

使用NSSet而不是数组(去除重复订购的产品)可能会更快,但是否则您的解决方案目前处于最佳状态。 (类似于realm cocoa:谓词选择不相关的项目 )。