views:

549

answers:

1

InterfaceBuilder generates this method for me in fooAppDelegate.m:

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    // Override point for customization after app launch    

    [window addSubview:[navigationController view]];
    [window makeKeyAndVisible];
}

IB also puts UIWindow *window; in fooAppDelegate.h and @synthesize window; in fooAppDelegate.m, and correspondingly for navigationController. IB generates code to release window and navigationController in dealloc.

I cannot see any code that allocates and initializes the window and the navigationController. I wonder where that happens.

Ari.

+5  A: 

Inside of the XIB file, there is code that instantiates the objects that are stored inside of it.

That is why the UIWindow instance is a IBOutlet. Anything that is a IBOutlet is typically instantiated from the XIB file.

Interface Builder is NOT a code generator, it's a live object factory.

"Interface Builder saves an application's interface as a bundle that contains the interface objects and relationships used in the application. These objects are archived (a process also known as serialization or marshalling in other contexts) into either an XML file or a NeXT-style property list file with a .nib extension. Upon running an application, the proper NIB objects are unarchived, connected into the binary of their owning application, and awakened"

Jacob Relkin
Technically, the XIB file is just data.The code that creates the objects from the nib is part of UIKit.
Mark Bessey
@Mark, Technically everything is "just data" :)
Jacob Relkin
Thank you for the explanation. What makes this "IB is not a code generator" business confusing for me is that IB does generate some code--including what I post in my original question.
iter
@iter Nope. That code is generated from the application template.
Jacob Relkin