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

      

  • 相关阅读:
    CSP 命令行选项(201403-3)
    ElasticSearch7.10的查询数据-简单查询
    ElasticSearch 种映射参数详解-理论学习02
    Elasticsearch7.10 -理论学习01
    ElasticSearch7.10索引
    ElasticSearch7.10的分词器
    ElasticSearch-7.10安装-2
    ElasticSearch第一天
    Idea的注释配置
    深圳第一站被骗消费3960元
  • 原文地址:https://www.cnblogs.com/lgphp/p/4109572.html
Copyright © 2011-2022 走看看