8.10.2. Forwarding Hook
8.10.2 Forwarding Hook
The GNU Objective-C runtime provides a hook, called __objc_msg_forward2
, which is called by objc_msg_lookup()
when it can't find a method implementation in the runtime tables and after calling +resolveInstanceMethod:
and +resolveClassMethod:
has been attempted and did not succeed in dynamically registering the method.
To configure the hook, you set the global variable __objc_msg_forward2
to a function with the same argument and return types of objc_msg_lookup()
. When objc_msg_lookup()
can not find a method implementation, it invokes the hook function you provided to get a method implementation to return. So, in practice __objc_msg_forward2
allows you to extend objc_msg_lookup()
by adding some custom code that is called to do a further lookup when no standard method implementation can be fo