let DIC:ns dictionary = self . mj _ key values()
let Data:Data = nskeydarchiver . archived Data(with root object:DIC)
let doc:String = NSSearchPathForDirectoriesInDomains(file manager。搜索路徑目錄.文檔目錄,文件管理器。searchpathdomainmask . userdomainmask,true)。最後!
假設path = doc . appending("/log in user . data ")
做{
try data.write(收件人:URL(文件URLWithPath: path))
}
接住{
打印(“r保存失敗”)
}
}
func synchronousData(){
let doc:String = NSSearchPathForDirectoriesInDomains(file manager。搜索路徑目錄.文檔目錄,文件管理器。searchpathdomainmask . userdomainmask,true)。最後!
假設path = doc . appending("/log in user . data ")
let data:NSData?= NSData(內容文件:路徑)
if nil == data {}else{
let dictionary = nskeydunarchiver . unarchiveobject(with:data!作為數據)!as!NSDictionary
if dictionary.count & gt0?{
user model . default manage . setvaluesforkeys(字典為![字符串:任何])
if user model . default manage . token . null object()= = false {
user model . default manage . haslog in = true
}
}
}
?
}