Obj-C objects have two pointers?

What is the difference between the first and second pointer?

+4
source share
2 answers

objectis a variable that points to an instance NSObject. This instance is in memory at the address marked with # 2.

But the variable itself must exist somewhere, and it is located at the address you mark # 1.

Or, to look at it in another way, you can write NSObject *object;. The content objectis address # 2, but the location objectis addressC # 1.

+10
source

Simple image for clarity.

address1 - obejct address2 - `object '

, address1 address2

enter image description here

+3

Source: https://habr.com/ru/post/1658442/


All Articles