因此自动合成属性非常棒.但是,当您同时提供getter和setter时,会出现错误.
@property (strong, nonatomic) NSArray *testArray;
- (NSArray *)testArray {
return _testArray;
}
- (void)setTestArray:(NSArray *)testArray {
_testArray = testArray;
}
Run Code Online (Sandbox Code Playgroud)
错误:Use of undeclared identifier '_testArray'.
添加@synthesize testArray = _testArray;解决了问题.我只是想知道为什么会这样?