Implementing Search Bar in Swift -
i have been trying implement search bar table view allow users search through transaction names.
this tutorial following: http://www.appcoda.com/search-bar-tutorial-ios7/
i have ran issues trying translate objective c code swift stuck @ 'filtercontentforsearchtext' line.
here code have search bar:
func filtercontentforsearchtext(searchtext: nsstring, scope: nsstring) { let resultpredicate = nspredicate(format: "name contains[c] %@", searchtext) searchresults = arraydatapayments.filteredarrayusingpredicate(resultpredicate) println(searchresults) } func searchdisplaycontroller(controller: uisearchdisplaycontroller!, shouldreloadtableforsearchstring searchstring: string!) -> bool { self.filtercontentforsearchtext(searchstring, scope: self.searchdisplaycontroller.searchbar.scopebuttontitles) return true }
could let me know going wrong?
you might have this:
self.filtercontentforsearchtext(searchtext: searchstring, scope: self.searchdisplaycontroller.searchbar.scopebuttontitles[self.searchdisplaycontroller.searchbar.selectedscopebuttonindex])
Comments
Post a Comment