ios - UITableView Search For Name In Object -
i trying search through array of objects retrieved parse display results in uitableview. tried using same method used in 1 of other apps, in case searching through array of strings.
this code @ moment:
func filtercontentforsearchtext(searchtext: nsstring) { let resultpredicate = nspredicate(format: "self beginswith[cd] %@", searchtext) //use either contains or beginswith searchresults = datamanager.sharedinstance.ridearray.name.filteredarrayusingpredicate(resultpredicate) } func searchdisplaycontroller(controller: uisearchdisplaycontroller!, shouldreloadtableforsearchstring searchstring: string!) -> bool { self.filtercontentforsearchtext(searchstring) return true } i understand why doesn't work, can't figure out solution problem. property want search within 'ride' object name.
can me out? thanks!
assuming ridearray array of parse objects have property name, predicate should be
nspredicate(format: "name beginswith[cd] %@", searchtext) and filter array with
ridearray.filteredarrayusingpredicate(searchpredicate)
Comments
Post a Comment