标签:
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSMutableArray *array = [NSMutableArray arrayWithObjects:@"3",@"2",@"5",nil];
NSArray* reversedArray = [[array reverseObjectEnumerator] allObjects];//倒序
for (id str in reversedArray) {
NSLog(@"%@",str);
}
}
return 0;
}
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
//查找名字里面包含“王”的姓
NSArray *array = [[NSArray alloc]initWithObjects:@"小王",@"王力",@"李丽",@"方方", nil];
NSString *match = @"*王*";
//查找姓王的名字,王字必须为首字则修改NSString *match=@"王*";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF like %@", match];
NSArray *results = [array filteredArrayUsingPredicate:predicate];
for (id str in results) {
NSLog(@"%@",str);
}
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/bobohahaha/p/5120738.html