Below is the corresponding code in the filterContentForSearchText:scope: method in MainViewController.m:
NSComparisonResult result = [product.name compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])]; if (result == NSOrderedSame) { [self.filteredListContent addObject:product]; }
This compares the first n characters (specified by the range parameter), ignoring the case and diacritics of each line with the first n characters of the current search line, where n is the length of the current search line.
Try changing the code to the following:
NSRange result = [product.name rangeOfString:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch)]; if (result.location != NSNotFound) { [self.filteredListContent addObject:product]; }
It searches for each row for the current search string.
source share