I would like to know if it is possible to filter an array which contain multiple set of words to obtain a filtered array that contains only words that start with a string using predicates:
I guess an example will talk by himself:
Array:
- green pepper
- white grapes
Filtered array for the @”pe”
- green pepper
Currently i am applying one predicate like the following:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF contains[c] %@",searchText];
NSArray *tempArray = [[self.searchContent objectAtIndex:INGREDIENT] filteredArrayUsingPredicate:predicate];
[self.ingredientsFiltered addObjectsFromArray:tempArray];
but this will give me both green pepper and white grapes as @”pe” is also a substring of pepper. Is there any recommended way to achieve this?
Try with this,