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

        //1.下标遍历

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

            NSString *str=[week objectAtIndex:i];

            NSLog(@"%@",str);//week[i]可以使用  不建议使用

        }

        //2.快速遍历   for in

        for (NSString *str in week) {

            NSLog(@"%@",str);

        }

        //id 代表任意类型  当不确定数组元素中的元素类型时,使用id

        for (id str in week) {

            NSLog(@"%@",str);

        }

相关文章:

  • 2021-10-28
  • 2022-12-23
  • 2021-06-07
  • 2022-01-20
  • 2021-07-22
  • 2021-07-24
  • 2022-12-23
  • 2021-12-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-26
  • 2021-10-10
  • 2021-12-28
相关资源
相似解决方案