Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C >> Capturing an Object Address in Memory

How do I capture the address of an object at a certain point in my code? for example:

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.
like image 725
Ohad Regev Avatar asked Dec 21 '22 03:12

Ohad Regev


1 Answers

Example:

NSString *temp = @"123";

uintptr_t ptrAddress = (uintptr_t) temp;

NSLog(@"%@ %p %lu", temp, temp, ptrAddress);

Console:

2013-07-11 11:51:20.796 asd[6474:907] 123 0x17985c 1546332

It may also be useful for you - NSPointerArray (iOS 6+)

like image 80
torip3ng Avatar answered Jan 07 '23 05:01

torip3ng