【发布时间】:2014-03-13 16:07:01
【问题描述】:
在 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
所以我想知道做类似事情的正确解决方案是什么,如果可能的话。如果需要编写访问器并避免使用自动合成等。请准确并通过文档或其他内容支持您的答案。
【问题讨论】:
-
我无法使用给定的代码重现警告。
-
我做了,是的,您需要将它放在单独的文件中才能拥有它(创建两个类)
-
任何我可以通过或忽略的标志来摆脱这个?
标签: ios objective-c properties warnings xcode5.1