views:

35

answers:

1

I was wondering why the retainCount of a viewController is raised by 4 when pushed onto the stack of a Navigationcontroller e.g. from a tableView. What dependencies are created?

+2  A: 

The retainCount method of the NSObject Protocol shouldn't be used for anything really. In fact, the documentation for this method says this:

This method is typically of no value in debugging memory management issues. Because any number of framework objects may have retained an object in order to hold references to it, while at the same time autorelease pools may be holding any number of deferred releases on an object, it is very unlikely that you can get useful information from this method.

If you are having memory management issues, make sure you've read the Memory Management Rules.

dreamlax
ok thanks, i wasn't having memory management issues, but was just curious. In this case I thought, the controller was pushed onto the stack and thus it had to be +1.
Icky