Cole Dennis
Apr 5, 2023

Hmm, I'm not entirely sure for the Forecast type - I think personally I would keep it an optional like this:

var hourlyWeatherForecast: Forecast<HourWeather>? {

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

print("Forecast: \(forecast)")

return forecast

}

And then wherever I'm working with it, include a fall back incase it returns nil:

Text(weatherKitManager.hourlyWeatherForecast?.forecast.first?.temperature.description ?? "error")

But maybe a different resource online might have a better solution? I wish you the best of luck and am excited to see whatever you end up building!

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

No responses yet

Write a response