zoukankan      html  css  js  c++  java
  • ios 几种快速写法

        //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"]);
    

      

  • 相关阅读:
    转载:Python十分钟入门
    Think Python: How to Think Like a Computer Scientist
    LeetCode(34):搜索范围
    LeetCode(33):搜索旋转排序数组
    LeetCode(32):最长有效括号
    LeetCode(31): 下一个排列
    LeetCode(30):与所有单词相关联的字串
    LeetCode(29): 两数相除
    LeetCode(28): 实现strStr()
    LeetCode(27): 移除元素
  • 原文地址:https://www.cnblogs.com/lgphp/p/4109572.html
Copyright © 2011-2022 走看看