如何过滤所有没有favoiritePosts数组中的ID之一的帖子?
我想过滤所有没有 favoritePosts 数组中的 ID 之一的帖子。 我尝试了这个,但它不起作用:
[NSPredicate predicateWithFormat:@"postID IN %@",favoritesPosts_];
我收到此错误:“无效谓词:nil RHS”
有关如何正确编写谓词的任何想法吗?
该数组由 NSNumber 对象组成,我想用这个谓词过滤我的 tableview 的 fetchResultController 。 Post 对象有一个 NSNumber 类型的 PostID 属性。
也许这不是这样做的方法。目标是在由 fetchResultsController 控制的表视图中仅显示其 id 位于 favoritesPosts_ 数组中的帖子。因此,如果有人对如何做到这一点有不同的想法,我将不胜感激。
I want to filter all the posts that don't have one of the IDs in the favoritePosts array.
I tried this but it doesn't work:
[NSPredicate predicateWithFormat:@"postID IN %@",favoritesPosts_];
I get this error: 'Invalid predicate: nil RHS'
Any ideas on how to write the predicate correctly?
The array is made of a NSNumber objects and i want to filter my tableview's fetchResultController with this predicate. the Post object has a PostID attribute which is of the NSNumber type.
Maybe thats not the way to do that.. The objective is to show in the tableview which is controlled by the fetchResultsController only the posts that their ids are in the favoritesPosts_ array. So if someone has a different idea on how to do that i will appreciate it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 favoritesPosts_ 是一个包含帖子 ID 的字符串数组,那么您可以很好地使用您创建的谓词,
但是如果 favoritesPosts_ 包含具有属性的对象,例如 < em>postID,那么你的谓词应该是,
If favoritesPosts_ is a string array containing the post IDs, then you can very well use the predicate you have created,
But if favoritesPosts_ contains objects which have a property, say, postID, then your predicate should be,