I just started learning iOS development. I’ve seen example code that creates a ViewController class for the sole purpose of initiating a UINavigationController, as shown below. What is the benefit of that, vs just creating a UINavigationController in the AppDelegate, and assigning it to self.window.rootViewController, as in snippet 2:
snippet1:
MyViewController *mvc = [[MyViewController alloc] init];
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:mvc] autorelease];
self.window.rootViewController = navController;
snippet2:
UINavigationController *navController = [[UINavigationController alloc] init];
self.window.rootViewController = navController;
The navigation view controller manages other view controllers, providing the interface for a stack-like structure to navigate through an application. If you just create a navigation controller without any view controllers to manage, it will have nothing to do or display. It might even cause an error (I haven’t specifically tried it).