1,数组NSArry/NSMutableArray
(1)不可变数组
NSArray*array1=@[@"a",@"b",@"c",@"d"];//创建 *是对象
NSLog(@"array1=%@",array1);
//数组元素个数.count
NSLog(@"count=%ld",array1.count);
//通过下标访问数组里面元素
NSString*str=array1[0];
NSLog(@"str=%@",str);
(2)可变数组NSMutableArray
NSMutableArray*mutableArray=[NSMutableArrayarrayWithObjects:@"1",@"2",@"3",@"4",nil];
NSLog(@"mutableArray=%@",mutableArray);
//元素个数:count
//添加个数
[mutableArrayaddObject:@"5"];
NSLog(@"已添加————————%@",mutableArray);
//移除
[mutableArrayremoveObject:@"3"];
NSLog(@"已移除-------%@",mutableArray);
2.字典_((存放多个键值对的一种数据类型)NSDictionary,NAMutableDictionary)
(1)不可变字典NSDictionary
NSDictionary*dict=@{@"key1":@"value1",@"key2":@"value2",@"key3":@"value3"};
NSLog(@"dict=%@",dict);
NSString*string=[dictobjectForKey:@"key1"];
NSLog(@"string=%@",string);
//所有key值,所有value值
NSLog(@"allkeys=%@,allvalues=%@",dict.allKeys,dict.allValues);
(2)可变字典