What I am trying to learn is what is the difference between the window, and viewcontroller. I know that you can only have one window per application. But you can have multiple viewcontrollers. When I create a project thats based off of the window-based application template I get only a window. I can create my own viewcontrollers, but I also know that I can put things directly onto the window in a window-based application (I think correct me if I am wrong). But with a view-based application I of course get a view that I can add things to. Can anyone clarify any of this for me if I make any sense?
Share
Basically you have one instance of
UIWindowthat’s hosting all yourUIViewControllersandUIViewsas part of the view hierarchy. That’s whyUIApplicationhas a call[UIApplication sharedApplication].keyWindow, to access the “root” view.So for example you can have the following stack:
[UIApplication sharedApplication].keyWindow->MyView->MyOtherViewControllerFor more information, read up the Developer Documentation on UIWindow and UIViewController which provide a great explanation on the differences.