How can I create a custom property in theos/logos?

1.1k Views Asked by At

Would it be possible to create a custom property in a hooked method using theos/logos?

example:

//define my custom property
@interface SBAwayController : NSObject {
    UIView *myCustomView;
}
@property (nonatomic, retain) UIView *myCustomView;
@end

%hook SBAwayController
- (void)activate {
    //call original method
    %orig;

    //use my custom property
    if (tweakEnabled)
        [self.awayView addSubview:myCustomView];
}
%end

I've tried it as exampled above, but no success.

1

There are 1 best solutions below

0
On

An alternative is to create a singleton class that will hold your object/context. Take this example from this Introspy hook class. tracerStorage is a variable defined outside the class and all hooks access it.

To apply it to your case, you can have an external variable NSMutableDictionary with the current SBAwayController as key and the property myCustomView as value.