如何在代码中的某个点捕获对象的地址?例如:
NSString * aString = @"bla bla";
//what is the current address of aString. i.e to which address in memory does it currently point to
aString = @"la la la";
//what is the current address of aString.
如何在代码中的某个点捕获对象的地址?例如:
NSString * aString = @"bla bla";
//what is the current address of aString. i.e to which address in memory does it currently point to
aString = @"la la la";
//what is the current address of aString.
例子:
NSString *temp = @"123";
uintptr_t ptrAddress = (uintptr_t) temp;
NSLog(@"%@ %p %lu", temp, temp, ptrAddress);
安慰:
2013-07-11 11:51:20.796 asd[6474:907] 123 0x17985c 1546332
它也可能对您有用 - NSPointerArray (iOS 6+)
这很容易,只需执行以下操作:
NSLog(@"%p", aString);
那是打印指针的格式规范。