ios - Where does filterContentForSearchText:scope: method come from? -
recently, noticed filtercontentforsearchtext:scope:
appeared in multiple tutorials regarding how implement search bar.
however, looked references of both uisearchdisplaydelegate , uisearchbardelegate
. found filtercontentforsearchtext:scope:
neither required nor optional method.
i wondered if filtercontentforsearchtext:scope:
conventional method name filtering search results?
yes, convention common method called uisearchdisplaydelegate
methods
- (bool)searchdisplaycontroller:(uisearchdisplaycontroller *)controller shouldreloadtableforsearchstring:(nsstring *)searchstring; - (bool)searchdisplaycontroller:(uisearchdisplaycontroller *)controller shouldreloadtableforsearchscope:(nsinteger)searchoption;
the current "simple uisearchbar state restoration" sample project apple not use convention:
- (bool)searchdisplaycontroller:(uisearchdisplaycontroller *)controller shouldreloadtableforsearchstring:(nsstring *)searchstring { nsstring *scope; nsinteger selectedscopebuttonindex = [self.searchdisplaycontroller.searchbar selectedscopebuttonindex]; if (selectedscopebuttonindex > 0) { scope = [[aplproduct devicetypenames] objectatindex:(selectedscopebuttonindex - 1)]; } [self updatefilteredcontentforproductname:searchstring type:scope]; // return yes cause search result table view reloaded. return yes; }
Comments
Post a Comment