swift - Why is rangeOfString returning a value instead of NSNotFound? -


debug image

in screenshot above can see rangeofstring has returned location "dent" in string "why #thisisacoup trending? - bbc news"

i expect have returned nsnotfound instead since "dent" not substring of string in tmp variable. can explain me why is?

here's code used in screenshot.

func searchbar(searchbar: uisearchbar, textdidchange searchtext: string) {      filtered = xmlparser.arrparseddata.filter({ (dict) -> bool in         let tmp: nsstring = dict["title"]!         let range = tmp.rangeofstring(searchtext, options: nsstringcompareoptions.caseinsensitivesearch)         return range.location != nsnotfound     })     if(filtered.count == 0) {         searchactive = false;     } else {         searchactive = true;     }     self.tableview.reloaddata() } 

your screenshot shows range.location = huge number. huge number nsnotfound (on 64-bit platforms); it's doing right thing.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -