Reputation: 91
I have a question,I don't know why Method 2 can't get value ?
Method 1:can get value!
-(void) searchBar:(UISearchBar *) searchBar textDidChange:(NSString *)searchText{
NSString *firstName = @"55566666666";
AllMainEventRows3 = [AllMainEventRows mutableCopy];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@",firstName];
NSArray *filteredArray = [AllMainEventRows3 filteredArrayUsingPredicate:predicate];
NSLog(@"filteredArray: %@", filteredArray);
}
LOG:
filteredArray: (
{
JoinSuccess = 55566666666;
bmabout = "";
bmaddr = "\U53f0\U5317\U5e02\U9752\U5cf6\U6771\U8def99\U865f10F-6";
})
Method 2:can't get value!
-(void) searchBar:(UISearchBar *) searchBar textDidChange:(NSString *)searchText{
AllMainEventRows3 = [AllMainEventRows mutableCopy];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@",searchText];
NSArray *filteredArray = [AllMainEventRows3 filteredArrayUsingPredicate:predicate];
NSLog(@"filteredArray: %@", filteredArray);
}
LOG:
filteredArray:(
)
Upvotes: 0
Views: 845
Reputation: 12671
textDidChange
Tells the delegate that the user changed the search text is delegate method of UISearchBarDelegate and it is called whenever text is changed within the search bar, I don't think the second method would get value because delegate methods are fired automatically means you are not calling them and you can not create multiple delegate methods with same name. you could declare some custom method for that purpose.
Problems in Predicate? would refer to usage of NSPredicate
Upvotes: 2