So, after initialization in the first line, error is a pointer to an NSError object.
In the first log, you register the address where this pointer is held. This is the effect of the operator and operator address. In any case, this address is passed to the doSomething method.
You go through: pointer -> pointer -> nserror-object.
But notice the double indirection in the doSomething signature. Auto-implement annotations make it difficult to detect, but its NSError ** .
So, the compiler takes your parameter and "expands" it twice.
It starts as a pointer -> pointer -> nserror-object. Then, after the first indirectness, it becomes a pointer β nserror-object. Then after the second indirection, it becomes an nserror object.
Ergo, you register two different things. The first is the address of the pointer to the nserror object. The second is the address of the nserror object itself.
EDIT: @MANIAK_dobrii indicates that the object pointed to by error is itself different in before and after.
It's true. If an error occurs in doSomething, it creates an entirely new instance of NSError in the else clause. Then it loads it back into the error pointer. This is why you see two different addresses, after which the error pointer points to another whole object.
source share