-(void)updateSearchResultsForSearchController:(UISearchController *)searchController { NSString *searchString = [self.searchController.searchBar text]; if (searchString.length == 0) { return; }NSPredicate *preicate = [NSPredicate predicateWithFormat:@"SELF CONTAINS[c] %@", searchS优艾设计网_设计模板tring]; if (self.searchResult!= nil) { [self.searchResult removeAllObjects]; }//过滤数据 self.searchResult= [NSMutableArray arrayWithArray:[self.datasource filteredArrayUsingPredicate:preicate]]; //刷新表格 [self.tableView reloadData]; }看例子的的排序都是对简单的字符串数组进行的筛选排序,对于字符串里是对象,按对象里的某个字符串进行筛选,这个可以做到吗?如果不能做到,那么一般用什么办法?以前都是直接用SQL来做的,这次需求里没用这个,能否直接在内容里进行这个
iOS NSPredicate 过滤排序?
-(void)updateSearchResultsForSearchController:(UISearchController *)searchController { NSString *searchString = [self.searchController.searchBar text]; if (searchString.length == 0) { return; }NSPredi
0
0
0
精彩评论