国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Objective-c - Why does the copy property in Object c return an object that is not a deep copy?
伊謝爾倫
伊謝爾倫 2017-05-02 09:35:32
0
2
793

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?

伊謝爾倫
伊謝爾倫

小伙看你根骨奇佳,潛力無(wú)限,來(lái)學(xué)PHP伐。

reply all(2)
過(guò)去多啦不再A夢(mèng)

copy是指在賦值的時(shí)候進(jìn)行一次copy操作,你可以再嘗試打印下s的地址,
ps: mutable類型的屬性別用copy

洪濤

Uh-huh. . You printed the same address three times, how can you change it?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template