When archive object in the func encode(with aCoder: NSCoder) method crashed with swift enum in real revice
问题 In my singleton class, I have a swift enum here: import UIKit enum UserType { case terant // case normalUser // case normalUserFinancialer // } @objc(UserStaticSwift) class UserStaticSwift:NSObject, NSCoding { The reported error : With the console log: libc++abi.dylib: terminating with uncaught exception of type NSException In the encode : func encode(with aCoder: NSCoder) { /* 基础 */ aCoder.encode(islogin, forKey: "islogin") aCoder.encode(type!, forKey: "type") // crash here in real device