如何在我的代码中的某个点捕获对象的地址? 例如:
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+)
关于Objective-C >> 获取内存中的对象地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17588679/