Is there any better way to get the memory address than this?
NSLog(@"%p", anObject);
I would rather get the plain long value.
Also you can caste some Type* to intptr_t, and look at this address in decimal representation:
Type*
intptr_t
NSLog(@"%lu", (uintptr_t)anObject);
To represent pointer address as integer in C exists 2 types: intptr_t and uintptr_t.
uintptr_t
intptr_t is defined as __darwin_intptr_t. and __darwin_intptr_t defined as long:
__darwin_intptr_t
long
typedef long __darwin_intptr_t;
uintptr_t defined as unsigned long:
unsigned long
typedef unsigned long uintptr_t;
I think what for uintptr_t I should use %lu and for intptr_t I should use %li:
%lu
%li
NSLog(@"%lu", (uintptr_t)anObject); NSLog(@"%li", (intptr_t)anObject);
Also you can caste some
Type*tointptr_t, and look at this address in decimal representation:To represent pointer address as integer in C exists 2 types:
intptr_tanduintptr_t.intptr_tis defined as__darwin_intptr_t.and
__darwin_intptr_tdefined aslong:uintptr_tdefined asunsigned long:I think what for
uintptr_tI should use%luand forintptr_tI should use%li: