views:

56

answers:

1

I init a navigation controller with:

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:firstViewController];

I wonder if the navigation controller retains firstViewController or that I need to keep it alive. When I release firstViewController, the navigation controller still works. That seems wrong.

Clarifications?

+2  A: 

If it needs to keep it around it will retain it. So yeah, you'll be safe to release it if you don't need it anymore. It's not just initWhatever methods that have this behaviour - it's the standard operation of the whole memory management model.

Carl Norum
true for everything but delegates. If an init takes a delegate in it will not retain it. This is in line with no one should retain delegates.
Brandon Bodnár
Thanks, that's clear. The firstViewController is expressly made to pass on to the UINavigationController through the initWithRootViewController, so *I* don't need it anymore. UINavigationController does, but that's its responsibility.Thanks for reinforcing that. Can't be done enough.
Thaurin