Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAnthony Attard
43,915 PointsWhy does var dailyWeather: DailyWeather? come before the outlets?
Why does var dailyWeather: DailyWeather? come before the outlets? Wouldn't we solve the issue of outlets not updating if we moved var dailyWeather after the outlets?
1 Answer
Gwinyai Nyatsoka
7,428 PointsThe outlets are only updated when the view is fully loaded so they still won't update even if we put them after. var dailyWeather: DailyWeather uses a property observer didSet{} which is initialised by the prepareForSegue method. When this happens it calls the configureView method which does the job of updating outlets but it tries to do so when the view has not yet loaded. This is why we call configureView again in the viewDidLoad method which is a method that is automatically called when the view has fully loaded.