0
votes

I am confused by the relationship between the appDelegate, MainWindow and the various views (and corresponding contollers). What I want to achieve is to immediately after app launch, hand control over to a "mainController" class that in turn loads the nib-files as needed (to minimize program logic in the app delegate). First, I need to load a login screen, and after successful login the application content, whose logic I have read ideally should reside outside the appDelegate, hence the "mainController" class.

Does the "mainController" need to be connected with a (blank) nib-file? Should this mainController subclass the UIViewController class albeit it holds no GUI contents on itself and be instanciated with [window addSubview:mainViewController.view]; [window makeKeyAndVisible]; ? Or should I use the alloc/init syntax. In which case, how do I reference the window from the (sub)views in order to add views programmatically?

Any hints, tips or tutorials would be helpful.

1

1 Answers

1
votes

You can have both UIViewController that get its view from a XIB file and one where you build the UIViews and add them programmatically. It depends on the situation what is easiest. Interface Builder can not do all the things you can do by writing your own view, but for most of the views Interface Builder is enough.

You should start out reading this guide Apple made, it takes you through the different ways of using UIViewControllers:View Controller Programming Guide