Exceptions and Unrecognized Selectors

At runtime, when a message is sent to an object, that object goes to the class that created it and says, I was sent this message. Run the code for the matching method. This is different than in most compiled languages, where the method to be executed is determined at compile time.

How does an object know which class created it? It uses its isa pointer. Every object has an instance variable called isa. When an object is created, the class sets the isa instance variable of the returned object to point back at that class (Figure 2.20). It is called the isa pointer because an object is a instance of that class. Although you probably will never explicitly use the isa pointer, its existence gives ...

Get iOS 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.