首页 > 试题广场 >

NSMutableString * str = [[NSMu

[单选题]
NSMutableString * str = [[NSMutableString alloc] initWithFormat:@"123"];NSLog(@"str = %p",str);[str appendFormat:@"456"];NSLog(@"str = %p",str);
上面代码对字符串str进行拼接后,2次打印的地址是否相同:

  • 相同
  • 不同
  • 随机打印
  • 有时相同,有时不同
计算机种每个字节对应一个地址。变量的地址一般指它占用的第一个byte的地址
发表于 2019-09-01 21:42:08 回复(0)
NSString没有被替换掉,变的是_contents指针
发表于 2021-10-09 15:49:56 回复(0)