XCode 6.3 警告:合成 属性
XCode 6.3 Warning: synthesize property
在新的 Xcode 6.3 中,我收到此警告:
Auto property synthesis will not synthesize property 'homeInt'; it will be implemented by its superclass, use @dynamic to acknowledge intention
如何删除它?
我只是删除了这个 属性 声明,因为它已经在父 class
中声明了
如果您故意从超级 class 覆盖相同的 属性,那么在您的 *.m
或 *.mm
文件中,添加 @dynamic
之类的:
@implementation MyClass
@dynamic homeInt;
// ...
@end
如果不是,请重命名 属性。
这个原因由childclass定义相同的属性名称覆盖到parentclass,例如:
1)child class "AFHTTPSessionManager" 有定义:
@property (nonatomic, strong) AFHTTPResponseSerializer <AFURLResponseSerialization> * **responseSerializer**;
2)parent class "AFURLSessionManager" 有定义:
@property (nonatomic, strong) id <AFURLResponseSerialization> **responseSerializer**;
3)以上原因,警告来了!如果要删除它,只需重命名冲突 属性 名称即可!
4) 或者按照它的建议,在您的实现文件中添加“@dynamic homeInt”;
如果您想避免添加 @dynamic <varName>
每个您已覆盖超级 class 的 属性 有意 的地方,您可以在项目构建设置下将 -Wno-objc-property-synthesis
标志添加到 "Other Warning Flags"。这将在整个项目范围内抑制警告。
如果您更新到 Xcode 6.3,只需将 AFNetworking 更新到版本 2.5.2,这些警告就会消失。
根据@mplace 的评论,在我的例子中,我重写了 属性 以将 属性 的类型细化为原始 class 的子 class的 属性。所以,我确实需要 @属性 覆盖。
这是我正在使用的:
#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
注意是“-Wobjc-属性-synthesis”而不是“-Wno-objc-属性-synthesis”
另见 https://github.com/couchbase/couchbase-lite-ios/issues/660
@实现我的类
@synthesize homeInt = _ homeInt;
...
@结束
在新的 Xcode 6.3 中,我收到此警告:
Auto property synthesis will not synthesize property 'homeInt'; it will be implemented by its superclass, use @dynamic to acknowledge intention
如何删除它?
我只是删除了这个 属性 声明,因为它已经在父 class
中声明了如果您故意从超级 class 覆盖相同的 属性,那么在您的 *.m
或 *.mm
文件中,添加 @dynamic
之类的:
@implementation MyClass
@dynamic homeInt;
// ...
@end
如果不是,请重命名 属性。
这个原因由childclass定义相同的属性名称覆盖到parentclass,例如:
1)child class "AFHTTPSessionManager" 有定义:
@property (nonatomic, strong) AFHTTPResponseSerializer <AFURLResponseSerialization> * **responseSerializer**;
2)parent class "AFURLSessionManager" 有定义:
@property (nonatomic, strong) id <AFURLResponseSerialization> **responseSerializer**;
3)以上原因,警告来了!如果要删除它,只需重命名冲突 属性 名称即可!
4) 或者按照它的建议,在您的实现文件中添加“@dynamic homeInt”;
如果您想避免添加 @dynamic <varName>
每个您已覆盖超级 class 的 属性 有意 的地方,您可以在项目构建设置下将 -Wno-objc-property-synthesis
标志添加到 "Other Warning Flags"。这将在整个项目范围内抑制警告。
如果您更新到 Xcode 6.3,只需将 AFNetworking 更新到版本 2.5.2,这些警告就会消失。
根据@mplace 的评论,在我的例子中,我重写了 属性 以将 属性 的类型细化为原始 class 的子 class的 属性。所以,我确实需要 @属性 覆盖。
这是我正在使用的:
#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
注意是“-Wobjc-属性-synthesis”而不是“-Wno-objc-属性-synthesis”
另见 https://github.com/couchbase/couchbase-lite-ios/issues/660
@实现我的类
@synthesize homeInt = _ homeInt; ...
@结束