What `isa` is for

January 28th, 2011

When using the debugger within Xcode, you see that each object has a isa variable. For those, like me, curious about what is does.

When you use alloc on a class, you are actually creating space in memory which is temporary filled, at the bottom of this space you point to another memory address. This memory address is the class object's meta self i.e. its object blue print. It is this memory address that "isa" holds. When it comes to creating (init'ing) the object, it uses this isa value to get the object blue print and fills in the temporary memory with the meaningful object data.

This alloc the init process is known as Two-Stage creation.

What do you think? Let me know by getting in touch on Twitter - @wibosco