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"]);
输出日志:
2016-01-25 14:51:39.136 WDLClock[2728:396830] nInt : 1
2016-01-25 14:51:39.136 WDLClock[2728:396830] nFloat : 1.1
2016-01-25 14:51:39.137 WDLClock[2728:396830] nDouble : 1.1111111
2016-01-25 14:51:39.137 WDLClock[2728:396830] nBool : 1
2016-01-25 14:51:39.137 WDLClock[2728:396830] nChar : 97
2016-01-25 14:51:39.137 WDLClock[2728:396830] nExpression : 30
2016-01-25 14:51:39.137 WDLClock[2728:396830] array1 : (
1,
2,
3,
4,
5
)
2016-01-25 14:51:39.138 WDLClock[2728:396830] array2 : (
1,
2,
3,
4,
5
)
2016-01-25 14:51:39.138 WDLClock[2728:396830] array1-1 : 2
2016-01-25 14:51:39.138 WDLClock[2728:396830] array2-2 : 3
2016-01-25 14:51:39.138 WDLClock[2728:396830] dict1 : {
age = 26;
name = wangdalei;
sex = "\U7537";
}
2016-01-25 14:51:39.138 WDLClock[2728:396830] dict1[@"name"] : wangdalei
2016-01-25 14:51:39.138 WDLClock[2728:396830] dict2[@"name"] :moxi90
2016-01-25 14:51:39.139 WDLClock[2728:396830] dict2[@"age"] : 90
再添加一个关于Mutable的变量的声明:
NSMutableArray *ar3 = [@[@"2",@"6",@"5",@"4",@"3"] mutableCopy];
NSMutableDictionary *dic3 = [@{@"xxxx":@"2",@"wwww":@"w",@"eeee":@"e",@"rrrr":@"r"} mutableCopy];