ios - In an AppDelegate, how is the main UIWindow instantiated? -


a snippet of default code in master-detail xcode project


appdelegate.m

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {     // override point customization after application launch.  uinavigationcontroller *navigationcontroller = (uinavigationcontroller *)self.window.rootviewcontroller;  // *** here ***     masterviewcontroller *controller = (masterviewcontroller *)navigationcontroller.topviewcontroller;     controller.managedobjectcontext = self.managedobjectcontext;     return yes; } 

appdelegate.h

@property (strong, nonatomic) uiwindow *window; 

i aware @synthesize sets accessor methods, , no initialization happens automagically. how window have non-nil rootviewcontroller if never explicitly initialized? xcode init'ing behind scenes?

from my book:

if choose storyboard option specify template, process works little differently. app given main storyboard, pointed info.plist key “main storyboard file base name” (uimainstoryboardfile). after uiapplicationmain instantiates app delegate class, asks app delegate value of window property; if value nil, window created , assigned app delegate’s window property. storyboard’s initial view controller instantiated , assigned window’s rootviewcontroller property, result view placed in window root view; window sent makekeyandvisible message. of done behind scenes uiapplicationmain, no visible code whatever. why, in storyboard template, application:didfinishlaunchingwithoptions: implementation empty.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -