Calling Overridden Class Methods in Objective-C From the Superclass

Saturday, 15th January 2011

I spent some time trying to work out how to call a class method that may have been overridden by a subclass.

Normally, you’d call a class method explicitly with the name of the class, e.g.:

[TheClass classMethod]

But in this case, I wanted to call the class method from within the superclass, and get the subclass’s implementation (if there is one).

In the end, it turned out to be very simple and obvious:

[[self class] classMethod]