對象聲明為
@interface MyClass : NSObject
@property (atomic, copy) NSMutableString *name;
@end
定義為
@implementation MyClass
@synthesize name;
@end
呼叫
MyClass *m = [[MyClass alloc] init];
NSMutableString *s = [[NSMutableString alloc] initWithString:@"Hello"];
[m setName:s];
NSLog(@"%p", [m name]);
NSLog(@"%p", [m name]);
NSLog(@"%p", [m name]);
如果說copy每次回傳的物件對於可變字串都是深拷貝的話,為什麼列印的位址是一樣的?