I have a searchBar
and a searchController
in my project. I want to be able to search for a specific sequence of letters and possibly skipping a character or two if possible. For example if I search for "iPhone" or "i-phone" or "i phone" or "piphone" or "phone" i want to be able to still find the search term "iphone" in the list. Any help would be appreciated.
Where searchTerm is an all uppercase string from UISearchBar
NSCharacterSet *allowedChars = [[NSCharacterSet characterSetWithCharactersInString:@" ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890"] invertedSet];
NSString *resultString = [[searchTerm componentsSeparatedByCharactersInSet:allowedChars] componentsJoinedByString:@" "];
Taking in mind that the @" " in the allowsChars is essential because the actual search could be @"iPhone 32gb" etc...