iter
iter

Reputation: 4303

iPhone application lifecycle

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.

Upvotes: 2

Views: 3034

Answers (1)

Jacob Relkin
Jacob Relkin

Reputation: 163228

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"

Upvotes: 5

Related Questions