集合类
OC中的集合类 字典
数组
字符串
set
对于可变类型
NSMutableArray *names = [NSMutableArray arrayWithObjects:@"tian",@"zhang",nil];
NSMutableArray *namesCopy = [names copy];
NSMutableArray *namesMutableCopy = [names mutableCopy];
NSLog(@"%p %p %p",names,namesCopy,namesMutableCopy);
结果:0x100600fb0 copy:0x100601ad0 mutableCopy:0x100601af0
对于不可变类型
NSArray *names = [NSArray arrayWithObjects:@"tian",@"zhang",nil];
NSArray *namesCopy = [names copy];
NSArray *namesMutableCopy = [names mutableCopy];
NSLog(@"%p copy:%p mutableCopy:%p",names,namesCopy,namesMutableCopy);
结果:0x100500c30 copy:0x100500c30 mutableCopy:0x100500f50
总结
1.对集合类可变结合类型 浅拷贝
和 深拷贝
都是深拷贝
2.对于集合类不可变类型浅
即 浅
深
即深
3.对于非集合类型 同第二条