I’m trying to save an array of a custom object (DreamSign) to user preferences. One of the properties of DreamSign is also a custom enum. I found out I have to encode these objects to NSData in order to save them. Is there a section of any of the big nerd ranch books that can help with this? I have the swift book, and I was last in the properties section.
I’ve tried a few ways but I can’t figure it out with the info that’s online. This is the struct I’m trying to encode.
struct DreamSign {
var name = "Default Dream Sign"
var dreaminess = Dreaminess.neutral
enum Dreaminess: Int {
case neutral = 9
case somewhatLikely = 30
case likely = 50
case veryLikely = 90
case definetly = 99
}
}