I have the following method:
- (NSMutableArray *)getFilteredArrayFromArray:(NSMutableArray *)array withText:(NSString *)text {
if ([array count] <= 0)
First of all, you should not use stringWithFormat to build predicates. This can cause
problems if the search text contains any special characters like ' or ".
So you should replace
NSString *nameformatString = [NSString stringWithFormat:@"stationName contains[c] '%@'", text];
NSPredicate *namePredicate = [NSPredicate predicateWithFormat:nameformatString];
by
NSPredicate *namePredicate = [NSPredicate predicateWithFormat:@"stationName contains[c] %@", text];
To search within an array, you have to use "ANY" in the predicate:
NSPredicate *aToZPredicate =
[NSPredicate predicateWithFormat:@"ANY stationSearchData.browseAtozArray.city CONTAINS[c] %@", text];