Save struct in class to NSUserDefaults using Swift
问题 I have a class and inside the class is a (swift) array, based on a global struct. I want to save an array with this class to NSUserDefaults. This is my code: struct mystruct { var start : NSDate = NSDate() var stop : NSDate = NSDate() } class MyClass : NSObject { var mystructs : [mystruct] init(mystructs : [mystruct]) { self.mystructs = mystructs super.init() } func encodeWithCoder(encoder: NSCoder) { //let val = mystructs.map { $0 as NSObject } //this also doesn't work let objctvtmrec =