You have an array of mixed types ( NSString and NSDictionary ), which is usually a very bad idea (and will not be possible in Swift).
If for some reason you cannot control this and really need to filter through it, you need to check the validity of the comparison depending on the type:
NSIndexSet *matches = [arrmainData indexesOfObjectsPassingTest:BOOL^(id obj, NSUInteger idx, BOOL *stop) { NSString *stringToCompare = nil; if ([obj isKindOfClass:[NSString class]]) { stringToCompare = (NSString *)obj; } else { NSDictionary *dict = (NSDictionary *)obj; stringToCompare = dict["Name"]; } return [stringToCompare rangeOfString:searchString].location != NSNotFound; }]; NSArray *filteredArray = [arrmainData objectsAtIndexes:matches];
But then again, if you can really rethink mixing types in a single array, this is likely to lead to problems in the future.
source share