Object declared as
@interface MyClass : NSObject
@property (atomic, copy) NSMutableString *name;
@end
is defined as
@implementation MyClass
@synthesize name;
@end
Call
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]);
If the object returned by copy each time is a deep copy of the variable string, why are the printed addresses the same?
PHP中文网2017-05-02 09:37:32
Uh-huh. . You printed the same address three times, how can you change it?