中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

ios 遍歷數(shù)組的方法

2018-07-20    來源:open-open

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬Linux鏡像隨意使用

目前所知有七種方法

    //第一種  
    [arr enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOLBOOL *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循環(huán) for (int m = 0; m<[arr count]; m++) { NSLog(@"%@",[arr objectAtIndex:m]); } 

個(gè)人比較喜歡第一種方法

注意:

①  其中第二種方法由于是并行,所以打印出來的東西是隨機(jī)的,并不是按照順序打印的

②  第三種容易引起主線程堵塞,所以最好自己另外創(chuàng)建一個(gè)線程

來自:http://blog.csdn.net/lv_ruanruan/article/details/42426307

標(biāo)簽: isp

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:PHP 用 tidy_parse_file() 函數(shù)提取 HTML 中的鏈接

下一篇:通過深度優(yōu)先搜索產(chǎn)生的迷宮的Java代碼