Iphone – way to get the memory address of any object as an NSString

cocoa-touchiphoneuikit

I need to store the memory address of an Object as an NSString. Is there a special format specifier for that?

Best Answer

%p should work for any pointer, including pointers to objects. So:

NSString *addr = [NSString stringWithFormat:@"%p", obj];

That will be a string beginning with 0x and in hexadecimal.