WeatherKit Swift / REST mismatch? daytimeForecast and overnightForecast not available via Swift?

I am able to obtain daily forecasts via the REST API which include the daytimeForecast and overnightForecast records with their respective properties like cloudCover.

So far I have failed to access them via the Swift API:

forecast.daytimeForecast.cloudCover

results in: "Value of type 'DayWeather' has no member 'daytimeForecast'".

But if I print() the DayWeather objects, these members are actually printed with all their properties.

Is there a way to get them I am overlooking?

Answered by RK123 in 760551022

I was able to use the following code as a workaround 😬:

Mirror(reflecting: weather).descendant("daytimeForecast", "some", "cloudCover") as? Double ?? 0.0

Still no solution. I can access the property if I break into the debugger

(lldb) v weatherDataForDate.daytimeForecast.cloudCover
(Double) weatherDataForDate.daytimeForecast.cloudCover = 0.96999999999999997

But the respective code will not compile 😭

print(weatherDataForDate.daytimeForecast.cloudCover)

(Error: Value of type 'DayWeather' has no member 'daytimeForecast')

Accepted Answer

I was able to use the following code as a workaround 😬:

Mirror(reflecting: weather).descendant("daytimeForecast", "some", "cloudCover") as? Double ?? 0.0
WeatherKit Swift / REST mismatch? daytimeForecast and overnightForecast not available via Swift?
 
 
Q