在合成属性方面我有点困惑.
让我们说我的*.h文件中有这个属性.
@property (nonatomic, retain) NSString *aString;
Run Code Online (Sandbox Code Playgroud)
在我的*.m文件中我合成它.@synthesize aString;
我知道当我使用synthesize时,编译器将生成setter和getter.但这些孵化器和吸气器是怎样的?
当我给aString一个值时,哪些方法是正确的?
self.aString = @"My New String"; // This will use the setter?
aString = @"My new String"; //This will not use the setter and retain the string, right?
aString = [@"My new string" retain]; //This will not use the setter, but it will retain the string ?
[self setAString:@"My new string"]; //This will also use the setter?
Run Code Online (Sandbox Code Playgroud)
提前致谢!