I am trying to set my predicateWithBlock to receive the text of my search bar and filter all the results of my NSDictionary with the objects that have these texts. I have not used it then do not know what I'm doing wrong.
When I type something in the search bar I get this error "NSInvalidArgumentException ', reason:' - [__ NSDictionaryI hasPrefix]: unrecognized selector sent to instance 0x79866530"
Below is my code:
-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
if (searchText.length == 0) {
self.isFilltered = NO;
}else{
self.isFilltered = YES;
NSPredicate *evenNumbers = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
return [evaluatedObject hasPrefix:self.contactSearchBar.text];
}];
NSArray *filteredArray = [self.fakeData filteredArrayUsingPredicate:evenNumbers];
self.tableData = [@[@{@"rows": filteredArray}] mutableCopy];
[self.dataTableView reloadData];
}
}