It is my understanding that every view has it’s own controller class. I know generally that the xib file is the application view/subview. My question is does the MainWindow.xib have it’s own controller and if so, where can it be found?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You are right in that a xib file can allow to associate a view to its view controller.
Now, MainWindow.xib contains the main
UIWindowfor your app (at least).UIWindowis not aUIViewand does not need aUIViewController.On the other hand, you can create any object you like inside of a MainWindow.xib, so you can also have a
UIViewin there, which you then add to theUIWindowinstance, and its correspondingUIViewController.If you think about additional xibs, what happens with them is that they define a
UIView, and additionally also specify the File’s Owner type, which is usuallyUIViewControllerand gets instantiated by loading the xib.In this sense, MainWindow.xib, though not requiring a
UIViewController, still needs a File’s Owner, and this is theUIApplicationsingleton. Since you cannot modify nor derive a class fromUIApplication, the way to interact with theUIWindowinstance is through theUIApplication‘s delegate.Take in mind that MainWindow.xib plays a special role, in that it is also specified in the info.plist file. You can do without one (by removing the corresponding entry from info.plist) and simply declare your application delegate when calling
UIApplicationMainfrom main.c. In this case, nor application delegate neither the UIWindow will be instantiated through the xib mechanism; you will need to instantiate aUIWindowfrom you application delegate’sapplicationDidFinishLaunching.