我试图在游戏结束时存储一个值.
我正在使用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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。