为什么我们总是在Objective C中创建构造函数时这样做?
self = [super init];
if ( self ) {
//Initialization code here
}
Run Code Online (Sandbox Code Playgroud) 如果我以这种方式声明一个指针变量:
NSString *foo;
Run Code Online (Sandbox Code Playgroud)
然后在我的代码中的某个地方执行以下操作:
foo = @"bar";
Run Code Online (Sandbox Code Playgroud)
这最终是我的NSString,在内存中创建一个带有附加字符串的新副本,然后删除我的初始字符串?作为NSMutableString,foo会更好吗?