模糊搜索NSPredicate

孙辰阳
2023-12-01

//数据源

@property (nonatomic,strong)NSArray *nameArray;

//过滤后的数据源

@property (nonatomic,strong)NSMutableArray *result;

 




NSString *filterString =@"text";

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF contains [c] %@", filterString];

//过滤数据

    self.result = [NSMutableArray arrayWithArray:[self.nameArray filteredArrayUsingPredicate:predicate]];

 类似资料: