In one example code from Apple, they provide an example search:
for (Person *person in personsOfInterest) { NSComparisonResult nameResult = [person.name compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])]; if (nameResult == NSOrderedSame) { [self.filteredListContent addObject:person]; } }
Unfortunately, this search will match the text at the beginning. If you are looking for “John,” it will match “John Smith” and “Johnny Rotten,” but not “Peach John” or “John.”
Is there a way to change it to find search text anywhere in the title? Thanks.
source share