This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4518-demystifying-views-in-ios/lessons/5
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4518-demystifying-views-in-ios/lessons/5
Probably super.viewDidLoad()
is missing in LessonViewController
?
You can use it if you want. I think it’s unnecessary to include calls to super
methods, when we know that they don’t do anything. But there are good arguments to be made for calling them anyway.
Hi! Just out of curiosity, could you - as an alternative - achieve the same result in code simply by instantiating the view in code? And are there any perks of using the IB approach as opposed to the programmatic one?
Anything you can do with nibs/IB can be done in code. You’ll find as many opinions on what mix to use, as there are iOS developers! My preferred approach lines up pretty well with how team member Scott Berrevoets detailed how things are done at Lyft. I think Xcode’s tools are a win over pure code, and use them basically whenever possible in UIKit.
However, I always loathed the XML diffs from IB. SwiftUI solves this argument magnificently—I’m loving it and can’t wait for it to mature enough that it can completely replace UIKit.
Hi, the app crashes when I launch the application. The pb is in appDelegate class and the window variable. I can´t find why…
That’s not happening for me. Upload your version of the project and I’ll have a look!
I moved the code over to the sceneDelegate class under willConnectTo session method and everything is fine now.
@awaleh Glad you fixed it! Cheers! :]