gcc: Dynamically registering methods

1 
1 8.10.1 Dynamically Registering Methods
1 --------------------------------------
1 
1 If 'objc_msg_lookup()' does not find a suitable method implementation,
1 because the receiver does not implement the required method, it tries to
1 see if the class can dynamically register the method.
1 
1  To do so, the runtime checks if the class of the receiver implements
1 the method
1 
1      + (BOOL) resolveInstanceMethod: (SEL)selector;
1 
1  in the case of an instance method, or
1 
1      + (BOOL) resolveClassMethod: (SEL)selector;
1 
1  in the case of a class method.  If the class implements it, the runtime
1 invokes it, passing as argument the selector of the original method, and
1 if it returns 'YES', the runtime tries the lookup again, which could now
1 succeed if a matching method was added dynamically by
1 '+resolveInstanceMethod:' or '+resolveClassMethod:'.
1 
1  This allows classes to dynamically register methods (by adding them to
1 the class using 'class_addMethod') when they are first called.  To do
1 so, a class should implement '+resolveInstanceMethod:' (or, depending on
1 the case, '+resolveClassMethod:') and have it recognize the selectors of
1 methods that can be registered dynamically at runtime, register them,
1 and return 'YES'.  It should return 'NO' for methods that it does not
1 dynamically registered at runtime.
1 
1  If '+resolveInstanceMethod:' (or '+resolveClassMethod:') is not
1 implemented or returns 'NO', the runtime then tries the forwarding hook.
1 
1  Support for '+resolveInstanceMethod:' and 'resolveClassMethod:' was
1 added to the GNU Objective-C runtime in GCC version 4.6.
1