可以方便地过滤掉数组中不需要内容
举例:
过滤掉数组(Array<ExampleModel *>
)中name
不等于 A
或 B
的元素
@interface ExampleModel : NSObject
@property(nonatomic,copy)NSString * name;
@end
使用:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"NOT (name = %@ || name = %@ )", @"A" ,@"B"];
NSArray *filteredArray = [origArray filteredArrayUsingPredicate:predicate];
参考链接
http://nshipster.cn/nspredicate/
http://www.jianshu.com/p/88be28860cde