PDA

View Full Version : where is viewController initialized in AppDelegate?




kingthong
Apr 1, 2011, 10:34 AM
First off, nice April Fool's prank!

Second, this is a simple question but when i chose New Project -> View Based Application there is a viewController already created for me.

Now in my AppDelegate i have the following code by default:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Override point for customization after application launch.

// Add the view controller's view to the window and display.
[self.window addSubview:viewController.view];
[self.window makeKeyAndVisible];

return YES;
}


My question is where is the viewController being alloc and init'ed?
(Purely for knowledge purposes)



robbieduncan
Apr 1, 2011, 10:38 AM
I'm pretty sure it's deserialized from the main nib which is declared in the Info.plist file. But I am at work on a PC so can't check right now.

PhoneyDeveloper
Apr 1, 2011, 10:40 AM
Why don't you add this method to your view controller set a breakpoint in it and then tell us the answer?

-(id)initWithCoder:(NSCoder *)aDecoder
{
if ((self = [super initWithCoder:aDecoder]))
{
}

return self; // set a breakpoint on this line
}

dejo
Apr 1, 2011, 10:40 AM
My question is where is the viewController being alloc and init'ed?
It's done as part of MainWindow.xib.

kingthong
Apr 4, 2011, 01:58 AM
Thanks a lot guys.

was very helpful!