NSArray *arr = @[@"123",@"32",@"456",@"35"];
NSString *str = @"a2";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF CONTAINS %@",@"3"];
NSArray *resultArr = [arr filteredArrayUsingPredicate:predicate];//數(shù)組過(guò)濾
for (NSInteger i = 0; i < resultArr.count; i++) {
NSLog(@"%@",resultArr[i]);
}
if ([predicate evaluateWithObject:str]) {//字符串過(guò)濾
NSLog(@"包涵");
}
else {
NSLog(@"不包含");
}