Buscar en UITableView Agrupado
Soy nuevo en el desarrollo de Objective-C, y estoy tratando de filtrar el contenido de un UITableView agrupado.
Esto es lo que hice pero todavía no funciona:
- (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];
}
Cualquier sugerencia por favor