SearchBar method deprecated issue

408 Views Asked by At

I used this method but it's saying it is deprecated. Which method should I use instead of this method?

 -(BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString
    {
        [self filterContentForSearchText:searchString scope:[[self.searchDisplayController.searchBar scopeButtonTitles] objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]];

        return YES;
    }
2

There are 2 best solutions below

0
Lalit kumar On

UISearchDisplayController class replaces from UISearchController class

 - (void)updateSearchResultsForSearchController:(UISearchController *)searchController
 {
    // Your logic here
 }

 - (void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope
 {
  //[self updateSearchResultsForSearchController:searchController];
 }
0
user3182143 On

Apple Document Says

UISearchDisplayController is deprecated in iOS 8. (Note that UISearchDisplayDelegate is also deprecated.) To manage the presentation of a search bar and display search results in iOS 8 and later, instead use UISearchController.