This section is specific for the GNU Objective-C runtime. If you are using a different runtime, you can skip it.
The implementation of messaging in the GNU Objective-C runtime is designed to be portable, and so is based on standard C.
Sending a message in the GNU Objective-C runtime is composed of two separate steps. First, there is a call to the lookup function,
(or, in the case of messages to super,
). This runtime function takes as argument the receiver and the selector of the method to be called; it returns the
, that is a pointer to the function implementing the method. The second step of method invocation consists of casting this pointer function to the appropriate function pointer type, and calling the function pointed to it with the right arguments.
For example, when the compiler encounters a method invocation such as
, it compiles it into a call to
objc_msg_lookup (object, @selector(init))
followed by a cast of the returned value to the appropriate function pointer type, and then it calls it.