たとえば、既存のクラスのサブクラスを宣言する場合、theos では次のように記述できます。
%subclass NEWCLASS: EXISTINGCLASS
- (void)overridemethod {
//code
}
%new(v@:)
- (void)newmethod {
//code
}
%end
しかし、新しいクラスのメンバーまたはプロパティ変数を宣言する方法がわかりません...
どうすればよいですか?
はい、分かりました。
しかし、パッケージをコンパイルするとエラーが発生します..
私は以下のようにコードを書きました:
%subclass SBIconSubClass: SBIcon
%new
- (NSString *)aString {
return objc_getAssociatedObject(self, @selector(aString));
}
%new
- (void)setAString:(NSString *)value {
objc_setAssociatedObject(self, @selector(aString), value, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (id)application {
self.aString = @"Test";
NSLog(@"%@",self.aString);
return %orig;
}
%end
とエラー: