Osa
Osa

Reputation: 1990

Call different class method from my hooked class in theos

%hook FirstClass
 [self method2];
 %orig
%end

But method2 is only available at a different class

How can i call it in this case ?

What i know so far:

But this is way complicated, Is there any alternative way to do so

-- Update

I tried %c but i get this error

Tweak.xm:86:48: error: class method '+class' not found (return type
  defaults to 'id') [-Werror,-Wobjc-method-access]

                                           ^~~~~~~~~~~~~~~~~~

Applied solution in here > THEOS: compiling error when calling method in other class (logos)

But doesn't seem to work

Upvotes: 2

Views: 1985

Answers (1)

twodayslate
twodayslate

Reputation: 2833

To call a method of another class it will have to be a class method (plus sign). You can then do [%c(ClassName) method:]; If it is not a class method (minus sign) then you will have to have an instance of that class. Sometimes you can find a shared instance of a class and then use methods on that. [[%c(ClassName) sharedInstance].propertyWhichIsOfAClassYouActuallyWant method:]

Upvotes: 1

Related Questions