So I want a class to be able to store a “Class” object, then later call the static methods of that class…
Basically I have multiple classes that inherit a single class, so they all have the same static methods (but return different things). I want to be able to store which subclass I am using so I know which one to call the static methods of…
I know I can get the class with
Class something = [VirginMobile class];
But I can’t then do something like int i = [something staticMethodReturningInt];
Is there any way I can do this?
Cheers
I know you probably don’t want to hear that, but once you start being too clever with classes it’s a sure sign to use regular objects instead. I’m not sure if I understand your question correctly, but one way to solve issues with typing is to cast the receiver to
id:This will compile fine, as long as the compiler can see the definition of
methodReturningInt. And of course, at runtimeVirginMobilehas to respond to+methodReturningInt.