In my app I have 2 custom classes (super class and subclass) and based on them data is created and deleted from the user dynamically and I want to be able to save the data permanently with UserDefaults
and I'm not sure how.I tried looking the answers like this one - Saving custom SWIFT class with NSCoding to UserDefaults and I fint it hard to understand.
My first class(super class):
class Day {
var dayName: String
var subjects: [Subject]?
init(dayName: String) {
self.dayName = dayName
}
}
My second class(subclass):
class Subject: Day {
var subjectName: String
var startsAt: String?
init(dayName: String,subjectName: String) {
self.subjectName = subjectName
super.init(dayName: dayName)
}
}
Thanks for helping me.