Swift + Locksmith: do not store the value

I try to keep the value at the end of the game.

I am using the https://github.com/matthewpalmer/Locksmith updateData strong> method .

He talks about Github Repo

and also replacing existing data, it writes data to the keychain if it does not already exist

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

This is what I have:

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)")
}

This line print ("Ended (EndDateAndTimeString)") :

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

This print line ("Unable to set time") does nothing

This print line ("This line is complete") :

: print ( " END: (timeBattleEnded)" ) .

, po , , , .

- , ?

EDIT:

, . , , Keychain, . . , , . .

?

+4
2

matthew palmer:

, updateData , .

, , Locksmith.updateData, , . .

:

try Locksmith.updateData(["BattleEnd": "12345678", "Key2": "Value Two"], forUserAccount: "gameKeyChainValues")
+3

, , , , , . . , loadDataForUserAccount() .

+1

Source: https://habr.com/ru/post/1650349/


All Articles