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

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -