阅读背景:

ios高效开发-使用字面量语法让iOS代码更简洁漂亮

来源:互联网 
NSNumber *nInt = @1;
    NSNumber *nFloat = @1.1;
    NSNumber *nDouble = @1.1111111;
    NSNumber *nBool = @YES;
    NSNumber *nChar = @'a';
    
    NSLog(@"nInt : %@",nInt);
    NSLog(@"nFloat : %@",nFloat);
    NSLog(@"nDouble : %@",nDouble);
    NSLog(@"nBool : %@",nBool);
    NSLog(@"nChar : %@",nChar);
    
    int a = 5;
    int b = 6;
    NSNumber *nExpression = @(a*b);
    NSLog(@"nExpression : %@",nExpression);
    
    NSArray *array1 = @[@"1",@"2",@"3",@"4",@"5"];
    NSArray *array2 = @[@1,@2,@3,@4,@5];
    NSLog(@"array1 : %@",array1);
    NSLog(@"array2 : %@",array2);
    
    NSLog(@"array1-1 : %@",array1[1]);
    NSLog(@"array2-2 : %@",array2[2]);
    
    NSDictionary *dict1 = @{@"name":@"wangdalei",@"age":@26,@"sex":@"男"};
    NSLog(@"dict1 : %@",dict1);
    NSLog(@"dict1[@\"name\"] : %@",dict1[@"name"]);
    
    
    NSMutableDictionary *dict2 = [[NSMutableDictionary alloc]initWithDictionary:@{@"name":@"wangdalei",@"age":@26,@"sex":@"男"}];
    dict2[@"name"] = @"moxi90";
    dict2[@"age"] = @90;
    
    NSLog(@"dict2[@\"name\"] :%@",dict2[@"name"]);
    NSLog(@"dict2[@\"age\"] : %@",dict2[@"age"]);NSNumber *nInt = @1;
    NSNumber *nFloat = @1.



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: