Search code examples
iphoneobjective-ciosdebuggingretaincount

How to check the retain count while debugging


Does anybody know how can I check the retain count of an object while in debug mode? I have tried to add an expression [objInstance retainCount] but it did not work. I have also tried the print object PO [objInstance retainCount] in the console but again it did not work.


Solution

  • I am guessing you are talking about getting the retainCount in GDB?

    You can use the retainCount method.

    This is how I get in my Code.

    (gdb) p (int)[product retainCount]
    $2 = 4
    

    Hope this is what you are looking for.