In Objective-C, can we have a class Foo and a class Bar, and then do something like
Class aClass = [Foo class];
[aClass getURLString];
where getURLString is a class method of the class Foo or Bar. So in other words, invoke different class methods based on the class, and this class is referenced by a variable.
Foo and Bar have the same base class of NSObject in this example. I tried using the code above and it won’t work. If I use
id aClass = Foo;
or
id aClass = [Foo class];
It won’t work either. Must I instantiate a dummy object? Can Objective-C do it without instantiation?
What you’re trying should work fine. For example, the following works:
Is it possible you’ve neglected to
#importthe definition ofFoo?