语义问题:属性 的类型与访问器的类型不匹配
Semantic Issue: Type of property does not match type of accessor
我目前正在使用带有 iOS 10 SDK 的 theos 来尝试开发我的调整。我正在尝试将 NSString 设为 属性,然后对其进行合成。现在,我遇到了这个:"Semantic Issue: type of property 'systemVersion' does not match type of accessor 'setSystemVersion:'"
这是我的代码
@interface ALDevice : NSObject
{
NSString *_systemVersion;
}
@property(readonly, nonatomic) NSString *systemVersion;
- (void)setSystemVersion:(id)arg1;
@end
@implementation ALDevice
@synthesize systemVersion = _systemVersion;
- (void)setSystemVersion:(id)arg1{
//something
}
错误:
./ALDevice.h:13:42: error: type of property 'systemVersion' does not match type of accessor 'setSystemVersion:' [-Werror]
@property(readonly, nonatomic) NSString *systemVersion;
^
./ALDevice.h:19:1: note: declared here
- (void)setSystemVersion:(id)arg1;
有人知道如何解决这个问题吗?谢谢
由于 _systemVersion 是 readonly
属性,它会抛出错误,请改用 strong
。
@interface ALDevice : NSObject
{
NSString *_systemVersion;
}
@property(strong, nonatomic) NSString *systemVersion;
- (void)setSystemVersion:(id)arg1;
@end
我目前正在使用带有 iOS 10 SDK 的 theos 来尝试开发我的调整。我正在尝试将 NSString 设为 属性,然后对其进行合成。现在,我遇到了这个:"Semantic Issue: type of property 'systemVersion' does not match type of accessor 'setSystemVersion:'"
这是我的代码
@interface ALDevice : NSObject
{
NSString *_systemVersion;
}
@property(readonly, nonatomic) NSString *systemVersion;
- (void)setSystemVersion:(id)arg1;
@end
@implementation ALDevice
@synthesize systemVersion = _systemVersion;
- (void)setSystemVersion:(id)arg1{
//something
}
错误:
./ALDevice.h:13:42: error: type of property 'systemVersion' does not match type of accessor 'setSystemVersion:' [-Werror]
@property(readonly, nonatomic) NSString *systemVersion;
^
./ALDevice.h:19:1: note: declared here
- (void)setSystemVersion:(id)arg1;
有人知道如何解决这个问题吗?谢谢
由于 _systemVersion 是 readonly
属性,它会抛出错误,请改用 strong
。
@interface ALDevice : NSObject
{
NSString *_systemVersion;
}
@property(strong, nonatomic) NSString *systemVersion;
- (void)setSystemVersion:(id)arg1;
@end