I know nib files are serialized objects and they have owner, outlets to make connections.
Using XCode Navigation window template I created application, which in its order created 2 nib files – MainWindow and SecondView. I can’t understand how MainWindow is referring to SecondView, there is no connection between those two as far as I can see. SecondView’s owner is UIViewController and in MainWindow there is a navigation tab which is also UIViewController. But how they are connected in IB I can’t understand…
Also I don’t understand who is
instanciating MainWindow’s owner
object and where that object is being
kept, where is the variable which is
UIApplication myApp = [[UIApplication.
alloc] init]
This one is self-answered: UIApplicationMain and to have the instance variable I need to create outlet somewhere.
If I create 10 nib files with UIViewController owner, who will trigger their deserialization?
If some class is nib file’s owner, what is the essential responsibilities of that class? Is it deserializing nib file into memory?
Sorry for unorganized questions, I’ve been reading numerous articles and docs about nib files, but it is still confusing.
The MainWindow.xib is loaded when your app launches.
Open up the MainWindow.xib. Make sure you are in List View. You should see an instance of a UINavigationController. Inside that you should see an instance of UIViewController. Select the View Controller instance and take a look at the Inspector Panel. You should see that it has a property “Nib Name” which is set to “RootViewController”. So, the viewController will look for and load the “RootViewController” nib at runtime.
So, if you create 10 nibs you are responsible for the deserialization, but Interface Builder has ways to help you keep nibs small and manageable by packaging views in individual nib files.