在 XCode 5.1 中,会出现一个新警告。这让我明白——显然——我做错了什么。
这个想法是有一个对象(一个模型),它是从原始类继承的可变版本。所以这个想法是打开一个readonly
属性readwrite
@interface Car : NSObject
@property (strong, readonly) NSString *name;
@end
@interface MutableCar : Car
@property (strong, readwrite) NSString *name;
@end
这些需要在单独的文件中(如两个普通类)。
它给出了这个警告:
Auto property synthesis will not synthesize property 'name' because it is 'readwrite' but it will be synthesized 'readonly' via another property
所以我想知道做类似事情的正确解决方案是什么,如果可能的话。如果需要编写访问器并避免使用自动合成等。请准确并用文档或其他内容支持您的答案。