//查找名字里面包含“王”的姓
NSArray *array = [[NSArray alloc]initWithObjects:@"小王",@"王力",@"李丽",@"方方", nil];
NSString *match = @"*王*";
//查找姓王的名字,王字必须为首字则修改NSString *[email protected]"王*";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF like %@", match];
NSArray *results = [array filteredArrayUsingPredicate:predicate];
for (id str in results) {
NSLog(@"%@",str);
}
时间: 2024-12-18 12:27:22