問題:
[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (Installation) for key (root); the class may be defined in source code or a library that is not linked
一般出現(xiàn)在用archive序列化存儲一個對象A,然后后來的某個版本中在對象A中添加了屬性筏餐。然后解檔老的序列化數(shù)據(jù)時crash
NSKeyedArchiver.setClassName("Employee", for: Employee.self)
//before serializing
let employeeData = NSKeyedArchiver.archivedData(withRootObject: employee)
NSKeyedUnarchiver.setClass(Employee.self, forClassName: "Employee")
//before deserializing
NSKeyedUnarchiver.unarchiveObject(with: decoded) as? Employee