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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.