Dynamic method lookup and execution

A running Objective-C application consists largely of objects sending messages to each other. When an object sends a message, it kicks off a search for the method to execute. The search normally starts with the class referenced by the receiver’s isa pointer and then proceeds up the inheritance hierarchy until it finds a method of that name.

The dynamic search and the execution of the found method make up the basis of every Objective-C message send and are another feature of the Runtime.

Performing this lookup and executing the method is the job of the C function objc_msgSend(). This function’s arguments are the receiver of the message, the selector of the method to be executed, and any arguments ...

Get Objective-C Programming: The Big Nerd Ranch Guide 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.