In my class singleton, I have an listing swifthere:
import UIKit
enum UserType {
case terant
case normalUser
case normalUserFinancialer
}
@objc(UserStaticSwift)
class UserStaticSwift:NSObject, NSCoding {
Reported error:

With consolelog:
libc ++ abi.dylib: termination with an uncaught exception of type NSException
In encode:
func encode(with aCoder: NSCoder) {
aCoder.encode(islogin, forKey: "islogin")
aCoder.encode(type!, forKey: "type") // crash here in real device
aCoder.encode(forOcType, forKey: "forOcType")
aCoder.encode(username, forKey: "username")
aCoder.encode(password, forKey: "password")
aCoder.encode(userId, forKey: "userId")
codehere I archive my userStatic:
userStatic.addUserInfo(type: userStatic.type!, dic: userInfoDic, closure: { (void) in
let paths:NSArray = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) as NSArray
let path = paths.firstObject
let homePath = "\(path)/\(Global.archive_userStaticData)"
let _ = NSKeyedArchiver.archiveRootObject(userStatic, toFile: homePath)
})
My debugwhen archiveRootObject:

Magazine console:
(lldb) po NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) as NSArray
error: Couldn't materialize: couldn't get the value of void: extracting data from value failed
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
(lldb) po homePath
error: Couldn't materialize: couldn't get the value of void: extracting data from value failed
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
I tested in simulatorand device, in the simulatorproblem does not exist, the real deviceproblem comes out.