语义问题:属性类型与访问者类型

时间:2018-03-31 09:20:13

标签: ios objective-c jailbreak theos

我目前正在使用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
}

ERROR:

./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;

任何人都知道如何解决这个问题?感谢

1 个答案:

答案 0 :(得分:0)

由于_systemVersion属于readonly属性,因此会引发错误,请改为使用strong

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