Here's the model of the API that I'm using
// MARK: - Welcome
struct NOAAWeatherDecoder: Codable, Identifiable {
var id = UUID()
let type: String
let geometry: Geometry
let properties: Properties
enum CodingKeys: String, CodingKey {
case type, geometry, properties
}
}
// MARK: - Properties
struct Properties: Codable {
let updated: Date
let units, forecastGenerator: String
let generatedAt, updateTime: Date
let validTimes: String
let elevation: Elevation
let periods: [Period]
}
// MARK: - Elevation
struct Elevation: Codable {
let value: Double
let unitCode: String
}
// MARK: - Period
struct Period: Codable {
let number: Int
let name: String
let startTime, endTime: Date
let isDaytime: Bool
let temperature: Int
let temperatureUnit: TemperatureUnit
let temperatureTrend: JSONNull?
let windSpeed, windDirection: String
let icon: String
let shortForecast, detailedForecast: String
}
I am able to get upto periods
, but nothing after that. Here's the part of the code where I'm running into the issue
ForEach(noaaWeatherData.weathernoaadata) { day in Text(day.properties.periods[0]) After this I'm not entirely sure. }
Thanks!