I am certain that this is a duplicate of another answer, but I can't find it. If anybody can, please close this as a dupe.
Anyway, the IN
operator works nicely on strings. Apparently it is undocumented, so you will have to decide if you want to rely on it:
NSArray *cityArray = @[@"Chennai",@"Mumbai",@"Kolkata"];
NSString *scannedStr = @"Chennai Tnagar";
NSPredicate *pred = [NSPredicate predicateWithFormat: @"SELF IN[cd] %@", scannedStr];
NSArray *result = [cityArray filteredArrayUsingPredicate: pred];
This solution has the advantage of keeping the object of the predicate on the left, which I happen to find easier to read - but as mentioned, it is not documented.
In case you wish to use a documented construct, you can swap the order of the predicate and use a normal CONTAINS
:
pred = [NSPredicate predicateWithFormat: @"%@ CONTAINS[cd] SELF", scannedStr];