NSString *i = @"1";
NSString *j = [i mutableCopy];
NSLog(@"i=%p,j=%p",i,j);
打印地址不一样,由此可见是内容拷贝
继续
i = @"2";
NSLog(@"i=%@,j=%@",i,j);
那么问题来了,为什么j的值还是1?
天蓬老师2017-05-02 09:38:07
Content copy is a deep copy. The new j generated is a new object and has nothing to do with i. So changing i will not affect j.
为情所困2017-05-02 09:38:07
The addresses are different, which means they are two objects. So the question is, why are the values between two independent objects still related?