谓词搜索
1.测试模型
TestModel * model = [TestModel new];
model.name = name;
model.area = area;
model.company = company;
2.模型多字段匹配
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{ [self.results removeAllObjects];
NSPredicate *NamePredicate = [NSPredicate predicateWithFormat:@"name contains %@ || area contains %@ || company contains %@", searchText,searchText,searchText]; [self.results addObjectsFromArray:[self.datas filteredArrayUsingPredicate:NamePredicate]]; [self.tableView reloadData];
}