XCode 6.3 警告:合成属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29534654/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
XCode 6.3 Warning: synthesize property
提问by UnRewa
In new Xcode 6.3 I get this warning:
在新的 Xcode 6.3 中,我收到此警告:
Auto property synthesis will not synthesize property 'homeInt'; it will be implemented by its superclass, use @dynamic to acknowledge intention
自动属性合成不会合成属性 'homeInt';它将由其超类实现,使用@dynamic 来确认意图
How I can remove it?
我怎样才能删除它?
回答by Karmeye
If you are overriding the same property from the super class on purpose:
如果您有意覆盖超类中的相同属性:
@implementation MyClass
@dynamic homeInt;
...
If not, rename the property.
如果不是,请重命名该属性。
回答by stasick
I simply removed this property declaration, because it has already been declared in parent class
我只是删除了这个属性声明,因为它已经在父类中声明了
回答by Chris Prince
Following on @mplace's comment, in my case I was overriding the property to refine the type of the property to a subclass of the original class of the property. So, I did need the @property override.
根据@mplace 的评论,在我的情况下,我覆盖了该属性以将该属性的类型细化为该属性原始类的子类。所以,我确实需要@property 覆盖。
Here's what I'm using:
这是我正在使用的:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-property-synthesis"
// superclass type for currentValue was "id"
@property (nonatomic, strong) NSDate *currentValue;
#pragma clang diagnostic pop
Note that it's "-Wobjc-property-synthesis" and not "-Wno-objc-property-synthesis"
请注意,它是“-Wobjc-property-synthesis”而不是“-Wno-objc-property-synthesis”
See also https://github.com/couchbase/couchbase-lite-ios/issues/660
另见https://github.com/couchbase/couchbase-lite-ios/issues/660
回答by mplace
If you want to avoid adding @dynamic <varName>
each place that you have overridden a super class's property intentionally, you can add the -Wno-objc-property-synthesis
flag to "Other Warning Flags" under your projects build settings. This will suppress the warning project-wide.
如果您想避免添加有意@dynamic <varName>
覆盖超类属性的每个地方,您可以将标志添加到项目构建设置下的“其他警告标志”。这将抑制整个项目的警告。-Wno-objc-property-synthesis
回答by zmingchun
this cause by child class define the same property name override to parent class,such as:
1)child class "AFHTTPSessionManager" have define :
这会导致子类定义相同的属性名称覆盖父类,例如:
1)子类“AFHTTPSessionManager”已经定义:
@property (nonatomic, strong) AFHTTPResponseSerializer <AFURLResponseSerialization> * **responseSerializer**;
2)parent class "AFURLSessionManager" have define:
2)父类“AFURLSessionManager”有定义:
@property (nonatomic, strong) id <AFURLResponseSerialization> **responseSerializer**;
3)cause by above, warning come! if want remove it ,just rename the conflict property name!
4) or as it suggest, add "@dynamic homeInt" in your implement file;
3)以上原因,警告来了!如果要删除它,只需重命名冲突属性名称!
4)或者按照它的建议,在你的实现文件中添加“@dynamic homeInt”;
回答by Marcos Reboucas
If you updated to Xcode 6.3, simply update AFNetworking to version 2.5.2 and these warnings should disappear.
如果您更新到 Xcode 6.3,只需将 AFNetworking 更新到 2.5.2 版,这些警告就会消失。
回答by BrandonYum
@implementation Myclass
@实现我的类
@synthesize homeInt = _ homeInt; ...
@synthesize homeInt = _ homeInt; ...
@end
@结尾