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!

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 trial

iOS Enhance a Weather App with Table Views Implementing the Detail View Adding UI Elements

Anthony Attard
Anthony Attard
43,915 Points

Why 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

The 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.