苹果ios开发者

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
//第一种
[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]);
}
posted on 2016-02-16 09:29  苹果ios开发者  阅读(260)  评论(0编辑  收藏  举报