I have been attempting to obtain data persistence for a Swift array of a custom type using either CoreData or NSUserDefaults. However, all of my attempts thus far have had issues saving the custom type to disk. I have used CoreData in a previous app but was only saving Swift strings to the CoreData plist. My custom type (a Swift Struct) includes the following variable types:
NSDate
Bool
// An optional of another custom Swift Struct (containing an Enum and UIColor)
UIColor?
String?
String?
String?
I have attempted downcasting the array to NSData and then upcasting it upon retrieval but need to first downcast my array to AnyObject (which the compiler won't do).
I really could just use some tips in the right direction. Do I need to extend the struct to include an encoder and decoder to and from NSData? If so, how is this typical done?