Cole Dennis
Mar 30, 2023

Hi Bjorn, I did some quick tests on my end using the template from the article, and it looks like it works if you declare hourlyWeatherForecast as an optional by including a question mark like this:

var hourlyWeatherForecast: Forecast<HourWeather>? {

let forecast = (weather?.hourlyForecast) //TODO: handle error case

print("Forecast: \(forecast)")

return forecast

}

I believe this might be partially due to the fact that when the app first launches, the location is not yet known because the .task is still accessing CoreLocation, so in those very first moments, the weather data will be nil because it doesn't have any location to pull weather data from.

Hope this helps!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Responses (2)

Write a response