码迷,mamicode.com
首页 > 移动开发 > 详细

ios 几种快速写法

时间:2014-11-20 01:29:01      阅读:259      评论:0      收藏:0      [点我收藏+]

标签:blog   io   ar   os   on   div   log   cti   ad   

    //NSString ....
    NSString *str1 = @"str1";
    NSLog(@"str %@",str1);
    
    //NSArray
    NSArray *arr1 = @[@"one",@"two",@"three",@"four",@YES,@(NO),@1,@(2)];
    NSLog(@"count %d",arr1.count);
    NSLog(@"value %@",arr1[4]);
    
    //NSMutableArray
    NSMutableArray *arr2 = [@[@"oo",@"xxx"] mutableCopy];
    /*[@[@(1), @(2), @(3), @(4), @(5), @(6), @(7), @(8), @(9), @(10)] mutableCopy]
     NSMutableArray *arr2 = [@[
     [@{@"name" : @"Cersei Lannister", @"title" : @"Queen of the Seven Kingdoms", @"isFavourite" : @NO, @"image" : @"cersei" } mutableCopy],
     [@{@"name" : @"Jaime Lannister", @"title" : @"Kingslayer", @"isFavourite" : @NO, @"image" : @"jaime" } mutableCopy],
     [@{@"name" : @"Joffrey Baratheon", @"title" : @"The Illborn", @"isFavourite" : @NO, @"image" : @"joffrey" } mutableCopy],
     [@{@"name" : @"Tyrion Lannister", @"title" : @"The Halfman", @"isFavourite" : @NO, @"image" : @"tyrion" } mutableCopy],
     [@{@"name" : @"Tywin Lannister", @"title" : @"Lord of Casterly Rock", @"isFavourite" : @NO, @"image" : @"tywin" } mutableCopy]]
     mutableCopy];
     */
    [arr2 addObject:@"two"];
    NSLog(@"count %d",arr2.count);
    NSLog(@"value %@",arr2[1]);
    
    //NSDictionary
    NSDictionary *dic1 = @{@"key1":@"value1",@"key2":@"value2"};
    NSLog(@"count %d",dic1.count);
    NSLog(@"value %@",dic1[@"key1"]);
    
    //NSMutableDictionary
    NSMutableDictionary *dic2 = [@{@"key1":@"value1",@"key2":@{@"key22":@"value22",@"key222":@"value222"}}
                                 mutableCopy];
    NSLog(@"count %d",dic2.count);
    NSLog(@"value %@",dic2[@"key2"][@"key222"]);

  

ios 几种快速写法

标签:blog   io   ar   os   on   div   log   cti   ad   

原文地址:http://www.cnblogs.com/lgphp/p/4109572.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!