Reputation: 1634
What type of code is correct and how works each of them (what difference between first and second if the result the same):
in application:didFinishLaunchingWithOptions: to make first controller's view visible I can use such method:
[self.window addSubview:myController.view];
[self.window makeKeyAndVisible];
or
self.window.rootViewController = self.myController;
[self.window makeKeyAndVisible];
What are the diffs ?? And which is correct and more safely ?
Regards, Alex.
Upvotes: 1
Views: 127
Reputation: 25692
Window is also inherited from UIView
rootViewController is property of Window not from UIView.
The root view controller provides the content view of the window. Assigning a view controller to this property (either programmatically or using Interface Builder) installs the view controller’s view as the content view of the window. If the window has an existing view hierarchy, the old views are removed before the new ones are installed.
The default value of this property is nil.
addsubview method inherits from the UIView.
if u use this firsttime with ur window then same effect u will get.
Upvotes: 1