objective c - How to extend search with SearchBar -
I want to search it with an array through stars. So I use a search bar here my code is:
(items in NSString * string) {NSRange nameRange = [string rangeOfString: text options: NSCaseInsensitiveSearch]; If (nameRange.location! = NSNotFound) {[Filtered items array object: string]; }}
This works very well, but the problem is that when I write it exactly the same way (the case gets insensitivity except the string). But I have to find out that the strings are not consistent with 100%. For example, when I search for 'Ralle Turner', then it should also get a string with 'Raleigh / Ralph Turner'.
Thank you for helping people!
You need to split the search string into words, and then to search for a word, each Repeat through the word.
You can use this string inside your loop for
(NSString * string in items) {NSArray * words = [text componentsSeparatedByString: @ ""] ; For (words in NSString *) {NSRange nameRange = [string borderoffstring: word option: nscinsensitive search]; If (nameRange.location! = NSNotFound) {[Filtered items array object: string]; break; }}}
Comments
Post a Comment