Just Connect this method on Editing Changed Event
of your TextField
. So, this method is called when you are changing its value.
- (IBAction)txtValueChanged:(UITextField)sender
{
[self dynamicSearchInto:sender.text];
//From here, we are passing text of textField.
}
Here, allData
is an array
which contains all your data. And searchArray
is an array in which contains only searching data. So make sure that, you have to set count of searchArray
into tableview's
rows count. And setting data into tableview according to this searchArray
.
-(void)dynamicSearchInto:(NSString *)strText
{
if (strText.length != 0)
{
searchArray = [[NSArray alloc]init];
NSString *str=txtSearch.text;
NSPredicate *predicate=[NSPredicate predicateWithFormat:@"SELF['yourKey'] contains[c] %@", str];
searchArray = [allData filteredArrayUsingPredicate:predicate];
[myTableView reloadData];
}
else
{
searchArray = allData;
}
[myTableView reloadData];
}
Hope, this is what you're looking for. Any concern get back to me.