zoukankan      html  css  js  c++  java
  • Object-C 基础学习笔记(for,foreach,while,switch)

    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;
    }

  • 相关阅读:
    your account already has a valid ios distribution certificate
    uinavigation样式
    phonegap ios默认启动页
    git init出错
    ios assetlibrary
    uitableviewcell高度自适应笔记
    ios frame bounds applicationframe
    java学习笔记
    file not found while xcode archive
    c++回调
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4313661.html
Copyright © 2011-2022 走看看