where is viewController initialized in AppDelegate?

Discussion in 'iPhone/iPad Programming' started by kingthong, Apr 1, 2011.

  1. macrumors member

    Joined:
    Sep 20, 2010
    Location:
    Somewhere but not here.
    #1
    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:

    Code:
    - (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)
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    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.
     
  3. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #3
    Why don't you add this method to your view controller set a breakpoint in it and then tell us the answer?

    Code:
    -(id)initWithCoder:(NSCoder *)aDecoder
    {
    	if ((self = [super initWithCoder:aDecoder]))
    	{
    	}
    
    	return self;  // set a breakpoint on this line
    }
    
     
  4. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    It's done as part of MainWindow.xib.
     
  5. thread starter macrumors member

    Joined:
    Sep 20, 2010
    Location:
    Somewhere but not here.
    #5
    Thanks a lot guys.

    was very helpful!
     

Share This Page