I have a large number of Items in the core data.
Each Item has an attribute called “Source”, which is a string, indicating the Source this item belongs to.
When I fetch from the core data, I will fetch items from 10 sources (totally over 200 sources) each time and each time the 10 sources are randomly chosen before fetching.
How can I write the NSPredicate for this case?
If each time only fetch items from 1 source, it is easy:
NSPredicate *pred = [NSPredicate predicateWithFormat:@"Source like %@", @"source1"];
But what if it is 10 sources and change over time? do I need to write like
NSPredicate *pred = [NSPredicate predicateWithFormat:@"(Source like %@) AND (Source like %@) AND...", @"source1", @"source3", ...];
Thanks
1 Answer