标签:
数组遍历:
索引遍历
枚举遍历:
代码块遍历:
数组排序:
循环排序
代码块排序:
NSArray *array = @[@12,@23,@8];
NSComparator sortBlock = ^(id string1,id string2){
// return [string1 compare:string2];
if ([string1 floatValue]<[string2 floatValue]) {
return NSOrderedAscending;
}else if ([string1 floatValue]==[string2 floatValue]){
return NSOrderedSame;
}else{
return NSOrderedDescending;
}
};
NSArray *sortArray = [array sortedArrayUsingComparator:sortBlock];
NSLog(@"%@",sortArray);
}
数组逆序:
遍历逆序
方法逆序:
[[array reverseObjectEnumerator] allObjects];
标签:
原文地址:http://www.cnblogs.com/llhlj/p/5566344.html