So I have JSON data that's in an array (0 is first day of month up until last day of month).
How do I do a loop to go through the whole array and store the 3 times of the day each in their own array (I wish to use these times for notifications later)
The dayForArray variable is just the current day - 1 so that it matches the number in the JSON array.
func parseJSON(_ timesData: Data) -> TimesModel? {
let decoder = JSONDecoder()
do {
let decodedData = try decoder.decode(TimesData.self, from: timesData)
let time1 = decodedData.data[dayForArray].timings.Time1
let time2 = decodedData.data[dayForArray].timings.Time2
let time3 = decodedData.data[dayForArray].timings.Time3
let time = TimeModel(time1: time1, time2: time2, time3: time3)
return times
} catch {
delegate?.didFailWithError(error: error)
return nil
}
}
dayForArray, and you want it to apply to each day in the month?