Reputation: 25842
In my core data db, every item has a string id which is an url to indicate whom this item belongs to.
Now I have an array which contains, say, 200 owner urls (200 is just an example, it is dynamic in the app). I wish to fetch all items that belong to the 200 own urls.
If only 1 owner url, I know how to write:
[NSPredicate predicateWithFormat:@"(ownerUrl == %@)", url]
What about an array of owner urls, say 200?
by the way, the core data I am using is sql. I think sql will ignore "IN" in NSPredicate?
Thanks
Upvotes: 1
Views: 1161
Reputation: 38475
Try this :
NSSet *urls = [NSSet setWithObjects:@"url1", @"url2", @"url3", nil];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K IN %@", @"ownerUrl", urls];
Upvotes: 3