//? ? ? ? 數(shù)組(NSArray/NSMutableArray)
//? ? ? ? 不可變數(shù)組
NSArray *array1 = @[@"a",@"b",@"c",@"d"];
//創(chuàng)建
NSLog(@"array1 = %@",array1);
//? ? ? ? 數(shù)組元素個(gè)數(shù).count
NSLog(@"count = %ld",array1.count);
//? ? ? ? 通過下標(biāo)訪問數(shù)組里面的元素
NSString *str = array1[0];
NSLog(@"str = %@",str);
//? ? ? ? 可變數(shù)組NSMutableArray
NSMutableArray *mutableArray = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4", nil];
NSLog(@"mutableArray = %@",mutableArray);
//? ? ? ? 元素個(gè)數(shù):count
NSLog(@"count = %ld",mutableArray.count);
//? ? ? ? 添加個(gè)數(shù)
[mutableArray addObject:@"5"];
NSLog(@"已添加----%@",mutableArray);
//? ? ? ? 移除元素
[mutableArray removeObject:@"3"];
NSLog(@"已移除----%@",mutableArray);
//? ? ? 字典(存放多個(gè)鍵值對(duì)(key-value)的一種數(shù)據(jù)類型)
//? ? ? ? (NSDictionary,NAMutableDictionary)
//? ? ? ? 不可變字典NSDictionary
NSDictionary *dict = @{@"key1":@"value1",@"key2":@"value2",@"key3":@"value3"};
NSLog(@"dict = %@",dict);
NSString *string = [dict objectForKey:@"key1"];
NSLog(@"string = %@",string);
//? ? ? ? 所有的key值萝衩,所有的value值
NSLog(@"allkeys = %@,@allvalues = %@",dict.allKeys,dict.allValues);
}
return 0;
}