the requirement if ‘city” has been selected key in search field if user enters ‘brazil,austria’ , rows containing brazil or austria or both should shown in table.
any in regard helpful.i new cocoa
steps follow:
- find how cities there in search using regex. (by use of ,(comma))
- use predicate find cells contain city name.
- update table view cells result of predicate.
edit:
- create array of cities name
nsarray *cities = [searchstring componentsseparatedbystring:@","];
create set of unique results
nsmutableset *searchresultsset = [nsmutableset new]; for(int i=0;i<[cities count];i++) { nspredicate *resultpredicate = [nspredicate predicatewithformat:@"name contains[c] %@", [cities objectatindex:i]]; nsarray *searchresults = [recipes filteredsetusingpredicate:resultpredicate]; [searchresultsset addobjectsfromarray:searchresults]; }you have final result in set
searchresultsset. use show table view cell.nsarray *searchresults = [searchresultsset allobjects]; [self.tableview reloaddata];
you can use
nscompoundpredicate
Comments
Post a Comment