Instance methods in NSObject are also class methods in NSObject.
This works because of the way Objective-C performs dynamic dispatch. If you send a message to any object, the implementation of the method is viewed in the class of objects. If you send a message to a class, you send a regular message to the class object. There, the implementation is viewed in the so-called metaclass. Meta classes are automatically generated by the compiler. Class methods are just the methods of the metaclass instance. This is handled transparently by the compiler.
Inheritance also works at the metaclass level. Thus, the metaclass for a class is inherited from the metaclass of its superclass. We have two parallel inheritance hierarchies. Only root classes, such as NSObject, are handled differently. There, the metaclass cannot inherit from the metaclass of the superclass, since there is no superclass. For root classes, the meta class is inherited from the root class itself.
And since class class methods are instances of metaclass metaclass methods and NSObjects metaclasses that inherit from NSObject methods themselves, instance methods in NSObject are also class methods in NSObject.
source share