Invoked whenever a class or category is added to the Objective-C runtime; implement this method to perform class-specific behavior upon loading.
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+Beta
- tvOS 9.0+
- watchOS 2.0+
- Objective-C Runtime
load() message is sent to classes and categories that are both dynamically loaded and statically linked, but only if the newly loaded class or category implements a method that can respond.
The order of initialization is as follows:
All initializers in any framework you link to.
+loadmethods in your image.
All C++ static initializers and C/C++
_functions in your image.
All initializers in frameworks that link to you.
+loadmethod is called after all of its superclasses’
+loadmethod is called after the class’s own
In a custom implementation of
load() you can therefore safely message other unrelated classes from the same image, but any
load() methods implemented by those classes may not have run yet.