Object-C 基础学习笔记(for,foreach,while,switch)
2015-03-04 16:21
399 查看
int main(int argc, const char * argv[]) { //for,foreach,while,do-while,switch NSMutableArray* mutableArray = [NSMutableArray arrayWithCapacity:2]; [mutableArray addObject:@"item1"]; [mutableArray addObject:@"item2"]; [mutableArray addObject:@"item3"]; NSLog(@"-------------------for---------------------"); for(NSUInteger i=0;i<[mutableArray count];i++) { NSLog(@"%@",[mutableArray objectAtIndex:i]); } NSLog(@"-------------------foreach---------------------"); for (id item in mutableArray) { NSLog(@"%@",item); } NSLog(@"-------------------while---------------------"); NSUInteger count = 0; while (count < [mutableArray count]) { NSLog(@"%@",[mutableArray objectAtIndex:count]); count++; } NSLog(@"-------------------do-while---------------------"); count = 0; do{ NSLog(@"%@",[mutableArray objectAtIndex:count]); count++; }while (count<[mutableArray count]); NSLog(@"-------------------switch---------------------"); int expression=4; switch (expression) { case 1: NSLog(@"expression=1"); break; case 2: NSLog(@"expression=2"); break; default: NSLog(@"expression=default"); break; } return 0; }
相关文章推荐
- Object-C 基础学习笔记(for,foreach,while,switch)
- Python3学习笔记【基础3--list,tuple,if条件判断,for/while循环,dict字典,set集合】
- 学校学习ios教程笔记,第三节swift中的switch,for循环和while循环
- C++ Primer 学习笔记_19_语句 --if/switch/while/for语句
- 【Swift】学习笔记(五)——控制语句(if,switch,for-in,for,while,do-while)
- [汇编学习笔记]if/else,while,for,switch in Assembly Language
- Object-c基础编程学习笔记-对象初始化
- Java基础第一阶段——03_Java语言基础_运算符&if&while&switch&for语句
- java基础四(switch;for;while;do...while;break;continue;return)
- 学习笔记 -- Win32多线程程序设计(二) WaitForSingleObject and WaitForMultipleObjects
- rcnn学习笔记:Rich feature hierarchies for accurate object detection and semantic segmentation
- Shell Script学习笔记1:循环表达(for, while, until)
- 《笨办法学 Python》 学习笔记04 if-while-for
- if,continue,break,while,do-while, switch,return,foreach,for等条件语句的使用
- Kotlin学习笔记(4)-while&for
- c++学习 day2 循环学习(while do while for) 分支学习(if ; if else; if else if; switch的应用 )
- 【java基础知识(学习笔记)】--switch条件语句
- Object-c基础编程学习笔记-C的扩展
- 【学习笔记】Python基础-For与While循环
- 【转】R-CNN学习笔记2:Rich feature hierarchies for accurate object detection and semantic segmentation