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 fetchRes开发者_如何学编程ultController 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.
If favoritesPosts_ is a string array containing the post IDs, then you can very well use the predicate you have created,
predicateWithFormat:@"postID IN %@", favoritesPosts_];
But if favoritesPosts_ contains objects which have a property, say, postID, then your predicate should be,
predicateWithFormat:@"postID IN %@", [favoritesPosts_ valueForKey:@"postID"]];
精彩评论