Hi community,
I have data saved from a different view controller and I’m trying to print the result using my label on another view controller.
The app requires 3 inputs:
To test if I’m getting the data, I’m using JSONEncoder
func getSchedule(){
if let data = UserDefaults.standard.data(forKey: "sched recording") {
do {
// Create JSON Decoder
let decoder = JSONDecoder()
// Decode Note
let scheduleRecording = try decoder.decode(ScheduleRecording.self, from: data)
print("Recording info: \(scheduleRecording)")
} catch {
print("Unable to Decode Schedule Recording (\(error))")
print("No Schedule Recording")
}
}
else{
print("No Schedule Recording")
}
}
and the output on the console looks like this:
Recording info ScheduleRecording(startTime: 2022-08-15 17:00:00 +0000, endTime: 2022-08-15 05:00:00 +0000, repeatNum: 1)
Tried printing data on my label:
Now, I want to print the result on the app a bit neater. E.g.,
Start Time: x
End Time: y
Repeat: i
Is it possible to split the data I get from the decoder to do this?