Search code examples
iosobjective-cuisearchdisplaycontroller

searchDisplayController' is deprecated: first deprecated in iOS 8.0


Here my code: Need to remove my warning . i am under iOS 9

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{

    if (searchText.length>0) {

        self.searchBarActive = YES;



[self filterContentForSearchText:searchText scope:[[self.searchDisplayController.searchBar scopeButtonTitles]
                                                   objectAtIndex:[self.searchDisplayController.searchBar selectedScopeButtonIndex]]];

        [self.collectionView reloadData];
    }else{
        // if text lenght == 0
        // we will consider the searchbar is not active
        self.searchBarActive = NO;
    }



}

Need to remove my warning as i mention in my question.It should work with above iOS 7. I am new to ios. But need to remove my warning message .I have tried below code:

if([UISearchController class]){
//Create an UISearchController and add it to your UITableViewController
}else{
//Create an UISearchDisplayController and add it to your UITableViewController 
}

But seriously i don't know how to implement that .If any one help me with code explanation will be helpful me to know for further move.Thanks @@


Solution

  • .h

    @property (strong, nonatomic) UISearchController *searchController;

    .m

    [self filterContentForSearchText:searchText scope:[[self.searchController.searchBar scopeButtonTitles] objectAtIndex:[self.searchController.searchBar selectedScopeButtonIndex]]];
    

    this coding working well....