//第一种
[arr enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop){
NSLog(@
"%ld,%@"
,idx,[arr objectAtIndex:idx]);
}];
//第二种
dispatch_apply([arr count], dispatch_get_global_queue(
0
,
0
), ^(size_t index){
//并行
NSLog(@
"%ld,%@"
,index,[arr objectAtIndex:index]);
});
//第三种
dispatch_apply([arr count], dispatch_get_main_queue(), ^(size_t index){
//串行,容易引起主线程堵塞,可以另外开辟线程
NSLog(@
"%ld,%@"
,index,[arr objectAtIndex:index]);
});
//第四种
for
(NSString*str in arr) {
NSLog(@
"%@"
,str);
}
//第五种,do-while
int
i =
0
;
do
{
NSLog(@
"%@"
,[arr objectAtIndex:i]);
i++;
}
while
(i<[arr count]);
//第六种,while-do
int
j =
0
;
while
(j<[arr count]) {
NSLog(@
"%@"
,[arr objectAtIndex:j]);
j++;
}
//第七种,普通for循环
for
(
int
m =
0
; m<[arr count]; m++) {
NSLog(@
"%@"
,[arr objectAtIndex:m]);
}