u010944431
无知小呆
2015-11-13 14:23

NSString 引用计数 负1

  • nsstring
  • 计数

**_NSString *str = [[NSString alloc]init];
NSString *str7 = [[NSString alloc]initWithString:@"aaa"] //retainCount = -1
NSString *str8 = [[NSString alloc]initWithFormat:@"aaa"]; //retainCount = -1
NSString *str9 = [[NSString alloc]initWithFormat:@"a%s","aa"];//retainCount = -1
NSString *str4 = [NSString stringWithFormat:@"aaa"]; // -1

NSString str10 = [[NSString alloc]initWithFormat:@"啊"]; //retainCount = 1
NSlog(@"%d",str);
为什么中文的时候计数为1 英文时 alloc开辟空间为什么不计数

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐

换一换