NSString用copy和Strong修饰的区别

字数 14阅读 257

知乎相关链接:http://www.zhihu.com/question/20102376

@property (nonatomic, copy) NSString *cString;
@property (nonatomic, strong) NSString *sString;
NSMutableString *mString = [[NSMutableString alloc] initWithString:@"123"];
self.cString = mString;
self.sString = mString;
[mString appendString:@"abc"];
    
NSLog(@"coypString:%p---%@", self.cString, self.cString);
NSLog(@"strongString:%p---%@", self.sString, self.sString);
NSLog(@"mString:%p---%@", mString, mString);
  coypString:0xa000000003332313---123
strongString:0x7fae89576df0---123abc 
     mString:0x7fae89576df0---123abc

推荐阅读更多精彩内容