Home Can't save data from 2 custom classes with userDefaults
Reply: 0

Can't save data from 2 custom classes with userDefaults

user890 Published in July 16, 2018, 6:49 am

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.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.317955 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO