ios - view controller initilization -


usually view controller initialized in application delegate this:

- (bool)application:(uiapplication *)application         didfinishlaunchingwithoptions:(nsdictionary *)launchoptions  {     self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];      // override point customization after application launch     testviewcontroller *vc = [[testviewcontroller alloc] **init**];     self.window.rootviewcontroller = vc;     return yes; } 

but vc implement initialization method - (instancetype)initwithnibname:.

how init call initwithnibname:? call sequence?

if @ default implementation, calls superclass's version:

- (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil {     self = [super initwithnibname:nibnameornil bundle:nibbundleornil];     if (self) {         // custom initialization     }     return self; } 

implementing initwithnibname not required, since default init method call super implementation of initwithnibname:nibnameornil you.

if creating testviewcontroller using code (no xibs), code posted acceptable. otherwise, should call initwithnibname , pass name of nib used view controller.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -