Post

Replies

Boosts

Views

Activity

Reply to Hourly precipitation amounts seem drastically low
It's in the Codable JSON from HourWeather so it can be extracted from that. Perfectly normal way to extract data from an API. :P (I've noticed changes in the WeatherKit JSON between even minor iOS releases, so make sure to get some automated unit tests or something to catch if they change it again...) private struct SnowfallExtractor:Codable { let snowfallAmount: Measurement<UnitLength> static func extractSnowfall(hourWeather:HourWeather) -> Measurement<UnitLength>? { do { let jsonData = try JSONEncoder().encode(hourWeather) let snowfallExtractor = try JSONDecoder().decode(SnowfallExtractor.self, from: jsonData) return snowfallExtractor.snowfallAmount } catch { print("Error extracting snowfall:\(error)") return nil } } }
Mar ’24