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

      

  • 相关阅读:
    [CF451E] Devu and Flowers
    [CF1038E] Maximum Matching
    [CF825E] Minimal Labels
    [CCPC2020绵阳L] Lottery
    [CCPC2020绵阳K] Knowledge is Power
    [CCPC2020绵阳J] Joy of Handcraft
    [CCPC2020绵阳G] Game of Cards
    [CCPC2020绵阳D] Defuse the Bombs
    [CF1082E] Increasing Frequency
    [CF301B] Yaroslav and Time
  • 原文地址:https://www.cnblogs.com/lgphp/p/4109572.html
Copyright © 2011-2022 走看看