Reputation: 2964
This question pertains to programmatic-only apps that don't use nib files where the storyboard has been removed and the window is created and given a root view in the app delegate. Some of the accepted answers I've read here appear to conflict with Apple's documentation, so tell me if this is correct:
When creating a UIViewController
, the methods that create its foundation should be placed in loadView
without calling super.loadView
:
override func loadView() {
// build something
buildSomething()
}
And the methods that make the final touches should be placed in viewDidLoad
with calling super.viewDidLoad
:
// view did load
override func viewDidLoad() {
super.viewDidLoad()
// arrange something that requires it be built first
arrangeSomething()
}
Or should super.viewDidLoad()
be called only in special situations? If so, what are they?
Upvotes: 3
Views: 480
Reputation: 437392
This is correct, that if you implement loadView
you should not call super
. As the documentation says:
Your custom implementation of this method should not call
super
.
But if you implement viewDidLoad
, you should always call super
.
Upvotes: 5