标签:nspredicate
1 字符串中查出保函某个字节
NSArray *array =@[@"123", @"234" , @"345"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF contains [cd] %@", "2"];
NSArray *filterdArray = [array filteredArrayUsingPredicate:predicate];
NSLog(@"%@", filterdArray );
2.查找封装model对象的数组,根据model的一个属性
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name == %@", "Ansel"];
NSArray *filteredArray = [array filteredArrayUsingPredicate:predicate];}
3.查询数组中字典莫一个Key的值
NSArray *array = @[ @{ @"lastName" : @"Turner" },
@{ @"firstName" : @"Ben", @"lastName" : @"Ballard",
@"birthday": @"1972-03-24 10:45:32 +0600" }
];
NSPredicate *predicate =
[NSPredicate predicateWithFormat:@"firstName like %@", @"firstName"];
NSArray *filteredArray = [array filteredArrayUsingPredicate:predicate];
标签:nspredicate
原文地址:http://blog.csdn.net/mingios/article/details/40861411