isa pointer in objective-c

ios, objective-c

Solution

The real benefit is a better understanding of the Objective-C runtime, which is actually quite complex compared to static languages like C++. The `isa` pointer, in practical terms, isn't really used all that much unless you're hacking the runtime to do something special. This guide has more info on how it is used by the runtime.

You shouldn't really use the `isa` directly in production code. It's like `retainCount` - it's important you understand it but you shouldn't ever call it.

Problem

From this reference: When a new object is created, memory for it is allocated, and its instance variables are initialized. First among the object’s variables is a pointer to its class structure. This pointer, called isa, gives the object access to its class and, through the class, to all the classes it inherits from. From what I could understand reading this and this, it allows, for one, to use introspection but in a pragmatic way (iOS development), what can a programmer benefit from knowing/understanding this special pointer?

Original source