I need an NSPredicate that compares a property to an array of wildcards. Something like...
NSArray *collection = @[@"Jerry*",@"George*",@"Elaine*"];
[NSPredicate predicateWithFormat:@"property LIKE IN %@", collection];
Is this possible?
I ended up using NSCompoundPredicate
to get this done. I was hoping there was a shorter route but it's fairly painless.
NSArray *collection = @[@"Jerry*",@"George*",@"Elaine*"];
NSMutableArray *thePredicateArray = [NSMutableArray arrayWithCapacity:3];
for (id *theItem in collection)
{
[thePredicateArray addObject:[NSPredicate predicateWithFormat:@"property LIKE %@",theItem]];
}
NSCompoundPredicate *theCompoundPredicate = [NSCompoundPredicate orPredicateWithSubpredicates:thePredicateArray];