使用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
因此,我想知道如何像这样做正确的解决方案,如果可能的话。是否需要编写访问器并避免使用自动综合,等等。请准确说明并支持您的答案与文档或其他内容。