标签:
NSArray *arr = @[@"beijing",@"shanghai",@"shenzhen",@"guangzhou",@"hangzhou"];
NSString *str = @"hang";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF CONTAINS %@",str];
NSLog(@"new arr: %@",[arr filteredArrayUsingPredicate:pred]);
Cocoa框架中的NSPredicate用于查询,原理、用法类似于SQL中的where,作用相当于数据库的过滤
标签:
原文地址:http://www.cnblogs.com/zshl/p/5560745.html