Messaging with IMPs and Selectors

The Objective-C runtime contains two functions that implement messaging:

id objc_msgSend(id self, SEL op, ...); 
id objc_msgSendSuper(struct objc_super *super, SEL op, ...); 

The objc_msgSend(id self, SEL op, ...) function is the key to the dynamism and flexibility of Objective-C. All the runtime’s data structures exist either to make the implementation of objc_msgSend(id self, SEL op, ...) possible or to optimize the implementation. The capability to add methods to an existing class, have one class pose as another, implement distributed messaging, and implement polymorphism results from the existence of objc_msgSend(id self, SEL op, ...).

When the Objective-C compiler encounters a messaging expression such ...

Get Cocoa® Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.