NSPredicate简单应用

1、筛选纯字符串数组的内容

NSArray *array = [[NSArray alloc]initWithObjects:@"beijing",@"shanghai",@"guangzou",@"wuhan", nil];
NSString *string = @"ang";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF CONTAINS %@",string];
NSLog(@"%@",[array filteredArrayUsingPredicate:pred]);

 输出结果是:

(
    shanghai,
    guangzou
)

 

参考地址:http://blog.csdn.net/ztp800201/article/details/8116081

你可能感兴趣的:(NSPredicate简单应用)