NSKeyedUnarchiver fails to decode a custom object in swift
问题 I'm trying a basic implementation of the NSCoding protocol in swift, but it seems I can't success to unarchive an object after it has been correctly archived. Here's my attempt import Cocoa class User: NSObject, NSCoding { var name: String init(name: String) { self.name = name } init(coder aDecoder: NSCoder!) { self.name = aDecoder.decodeObjectForKey("name") as String } func encodeWithCoder(aCoder: NSCoder!) { aCoder.encodeObject(name, forKey: "name") } } let user = User(name: "Gabriele") let