views:

879

answers:

2

When you create an application from the "View-Based" template in the iPhoneSDK the following code is generated. I basically understand what is happening here, but I do not see where window and viewController are instantiated. Any Help?

@class jojojViewController;

@interface jojojAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    jojojViewController *viewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet jojojViewController *viewController;

@end

===============================================

@implementation Test6AppDelegate

@synthesize window,mainView;    

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

    // Override point for customization after application launch
    [window makeKeyAndVisible];
}    

- (void)dealloc {
    [window release];
    [super dealloc];
}
@end
+4  A: 

They come from the MainWindow.xib (or similar) file in your project.

This is the file that in your info.plist is set as the application window. When your application starts this xib is loaded and the viewcontroller and window are unarchived and loaded.

Andrew Grant
+1  A: 

If you look in MainWindow.xib, the window and viewcontroller are assigned to your AppDelegate's window and viewController outlets, which instantiates them when the nib is loaded (right click on the AppDelegate to see it).

Jarin Udom