So this is the question. Why does it do it? Even when a do something like this
NSLog(@"view's retainCount %d", [viewController.view retainCount]);
it increments the retain count.
So this is the question. Why does it do it? Even when a do something like this
NSLog(@"view's retainCount %d", [viewController.view retainCount]);
it increments the retain count.
Don't look at the retain count.
The viewController's getter is holding it for you so it can return a reference for you to (in this case) access the "retainCount" variable. It is returning this reference as "autorelease", so it is not really perminantley holding the retain count.
For example, if you ran this NSlog function 5 times in a row, you might see the retainCount go up by 5, but if you created a UI button that called it - thus giving the autorelease the ability to kick-in between presses of the button - you would not see it going up forever.