Assume that I have a particular class of object that defines a class method returning simple information about that class, thus:
+ (NSInteger) defaultValueForClass {
return 5;
}
Now, imagine I have a series of subclasses, each of which overrides this method in order to supply different information. My question is this: how can I call that class method without knowing which concrete subclass is being actioned, in such a way that the relevant subclass method is used? I can’t simply go:
[[anObject class] defaultValueForClass]
…because the compiler does not at this point know about my custom subclass method.
Sorry about my previous post, I was wrong, just define a protocol and then check if your class conformsToProtocol, or check if the given class “isSubclassOfClass”