NSString *i = @"1"; NSString *j = [i mutableCopy]; NSLog(@"i=%p,j=%p",i,j); 打印地址不一样,由此可见是内容拷贝 继续 i = @"2"; NSLog(@"i=%@,j=%@",i,j); 那么问题来了,为什么j的值还是1?
认证高级PHP讲师
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.
The addresses are different, which means they are two objects. So the question is, why are the values between two independent objects still related?
ok, let me check the information first
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.
The addresses are different, which means they are two objects. So the question is, why are the values between two independent objects still related?
ok, let me check the information first