Поиск в сгруппированных UITableView
Я новичок в разработке Objective-C, и я пытаюсь отфильтровать содержимое сгруппированного UITableView.
Это то, что я сделал, но до сих пор не работает:
- (void)filterContentForSearchText:(NSString *)searchText scope:(NSString *)scope
{
NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"SELF CONTAINS[cd] %@", searchText];;
//activities is table that contains my objects that I display their contents in the table
self.filteredData = [activities filteredArrayUsingPredicate:resultPredicate];
}
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller
shouldReloadTableForSearchScope:(NSInteger)searchOption
{
[self filterContentForSearchText:[self.searchDisplayController.searchBar text] scope:
[[self.searchDisplayController.searchBar scopeButtonTitles]
objectAtIndex:searchOption]];
// Return YES to cause the search result table view to be reloaded.
return YES;
}
//activite is my object that I use to desplay its attribut in table
IPADActivity *activite ;
if (ThetableView == self.searchDisplayController.searchResultsTableView) {
activite = [self.filteredData objectAtIndex:indexPath.row];
}
else{
activite = [[objects
objectForKey:[objectsIndex objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row];
}
Любое предложение, пожалуйста