I have a table view and adding items to that like this.`
NSDictionary *memberInfo = [self.currentChannel infoForMemberWithID:memberID];
memberinfo=memberInfo;
cell.textLabel.text = [NSString stringWithFormat:@"%@",[memberinfo objectForKey:@"name"]];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",[memberinfo objectForKey:@"status"]];
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.detailTextLabel.backgroundColor = [UIColor clearColor];
return cell;
`and it was working fine.Now i want to add a searchbar on to that.i need to load the tableview according to the matched string.But i am loading the tableview like this.I know how to search in an array.I am using
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText.i want to load the table view according to the match of the searchstring ,Can anybody know this?
You can use NSPredicate inside your SearchBar delegate to filter your main array (members or whatever you named it) and catch the results in an another global declared array. Now reload your table with this filtered array.
Now in your tableview datasource methods, populate table using filtered array(_mArrFilteredList).