Search code examples
memoryretainnslog

Can you send retain counts to NSLog to aid learning?


Just curious if there is anyway to display an objects retain count using NSLog. I just want to print them out to console to help learn how retain/release is working in some simple code?

cheers -gary-


Solution

  • Not only is it possible, it's very easy too:

    NSLog(@"retain count=%d",[obj retainCount]);