I am using NSComparisonResult with my SearchController:
for (Annotation *ano in listContent) {
NSComparisonResult result = [ano.title compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])];
if (result == NSOrderedSame) {
[self.filteredListContent addObject:ano];
}
}
If I search for a string, it will find the result only if it starts with this string.
Record " My art gallery "
Search "My art gallery" <--- Found
Find "My" <--- Found
Search for "Art" <--- Not found
Search "Gallery" <--- Not found
How can I change my code so that I can find parts of a string as I showed above?
source
share