当前位置 : 主页 > 手机开发 > 其它 >

Swift Locksmith:不存储价值

来源:互联网 收集:自由互联 发布时间:2021-06-11
我试图在游戏结束时存储一个值. 我正在使用https://github.com/matthewpalmer/Locksmith updateData方法. 它在Github Repo上说 as well as replacing existing data, this writes data to the keychain if it does not exist alread
我试图在游戏结束时存储一个值.

我正在使用https://github.com/matthewpalmer/Locksmith updateData方法.

它在Github Repo上说

as well as replacing existing data, this writes data to the keychain if it does not exist already

try Locksmith.updateData([“some key”: “another value”], forUserAccount: “myUserAccount”)

这就是我所拥有的:

let dictionary = Locksmith.loadDataForUserAccount("gameKeyChainValues")

print("Ended \(EndDateAndTimeString)")

do {
   try Locksmith.updateData(["BattleEnd": "12345678"], forUserAccount: "gameKeyChainValues")

}
catch {
    print("Unable to set time")
}

print("This line ran")

if let timeBattleEnded = dictionary!["BattleEnd"] as? String {
    print("Stored for END: \(timeBattleEnded)")
}

此行打印(“Ended(EndDateAndTimeString)”)输出:

Ended 19:33:38+2016-08-05

此行打印(“无法设置时间”)不执行任何操作

此行打印(“此行运行”)输出:

This line ran

这一行:print(“存储为END

网友评论