zoukankan      html  css  js  c++  java
  • oc数组遍历

    #import <Foundation/Foundation.h>

    //数组遍历(枚举)对集合中的元素依此不重复的进行遍历

    int main(int argc, const char * argv[]) {

        @autoreleasepool {

    NSArray *arr=@[@"MON",@"TUE",@"WED",@"THU",@"FRI",@"SAT",@"SUN"];

        //下标遍历

            for (int i=0; i<[arr count]; i++) {

                

                NSString *element=[arr objectAtIndex:i];

                NSLog(@"%@",element);

            }

            NSLog(@" ");

            for (int i=0; i<[arr count]; i++) {

                NSLog(@"%@",arr[i]);

            }

            NSLog(@" ");

            //for in 遍历性高

            for (NSString *str in arr) {

                

                NSLog(@"%@",str);

            }

            NSLog(@" ");

            //id当 不确定数组元素的类型时,选择使用de

            //id NSObject instancetype

            for (id str in arr) {

                NSLog(@"%@",str);

            }

        

            

        }

        return 0;

    }

  • 相关阅读:
    [转] CNN工作步骤解析
    [转] Attention模型结构
    [转] Boost算法
    [转] GDBT详解
    [转] Noise Contrastive Estimation 噪声对比估计 资料
    [转] 对数似然与交叉熵
    [转] ELMO
    [转] Batch Normalization
    强化学习总结
    MySQL 与 Hive 逻辑相关
  • 原文地址:https://www.cnblogs.com/shaowenlong/p/5121733.html
Copyright © 2011-2022 走看看