Why do I need to write @synthesize when I provide getter and setter?
问题 So the auto synthesize of properties is awesome. However, when you provide both a getter and a setter, you get an error. @property (strong, nonatomic) NSArray *testArray; - (NSArray *)testArray { return _testArray; } - (void)setTestArray:(NSArray *)testArray { _testArray = testArray; } Error: Use of undeclared identifier '_testArray' . Adding @synthesize testArray = _testArray; solves the problem. I am just wondering why this is? 回答1: When you provide both getter and setter, there is often