语义问题:属性类型不匹配访问者的类型



我目前正在使用iOS 10 SDK的Theos尝试开发我的调整。我正在尝试制作NSString属性,然后将其合成。现在,我遇到了这一点:"语义问题:属性'Systemversion'类型不匹配访问者的类型'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;

有人知道如何解决这个问题吗?谢谢

as _systemversion是一个 readonly属性,它正在丢弃错误,请用户用户 strong代替。

@interface ALDevice : NSObject
{
    NSString *_systemVersion;
}
@property(strong, nonatomic) NSString *systemVersion;
- (void)setSystemVersion:(id)arg1;
@end

最新更新