How do you make an NSPredicate that finds all objects in an array that contain a certain letters?
NSMutableArray *testArray = [[NSMutableArray alloc] initWithObjects:@"abc",@"cba", @"bca", nil];
NSPredicate *p = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@",@"abc"];
NSMutableArray *result = (NSMutableArray *)[testArray filteredArrayUsingPredicate: p];
Result only contains one object, @”abc”… I want it to catch all words that have “abc” in them. (e.g “cba”, “cba”, “lllllllllbbacllllll” etc)..
There’s nothing wrong with the other answers. However, I wanted to suggest a different way to create the predicate: using a block.
And just for the fun, you can also write the predicate with a subquery. This is less efficient but it’s the shorter solution.