Hi all My small app is growing more sprawling and I'm looking for some best practice advice on the management/ownership of view controllers and navigation controllers.
Here's what I'm doing now:
- AppController is a singleton that creates and owns a UINavigationController instance. The app controller, and thus the navigation controller, can be globally accessed via a
+sharedController
like method. Every view controller in the app that wishes to push a new view controller, basically does this:
NextViewController * nextViewController = [[NextViewController alloc] init]; [[[AppController sharedController] navigation] pushViewController:nextViewController ...]; [nextViewController release];
In this way, all "leaf" views are responsible for creating the next view over and pushing it, and the navigation controller lives in one place that everyone can get to.
But I cooked this up myself. Since navigation through view controllers is such a critical piece of architecture, I'm wondering if anyone has a better or more thoughtful approach here.
Thanks.