ios - KeychainWrapper as a substitute for NSUserDefaults for storing highScore -


hi created app , use store highscores in nsuserdefaults , load highscore everytime game launched using code:

var highscore = nsuserdefaults.standarduserdefaults().integerforkey("highscore") 

then ive heard modified , thought use keychain. dont know keychain found swiftkeychainwrapper looked rather easy implement. using code

var highscorestring: string = keychainwrapper.stringforkey("highscore")! var highscore = int(highscorestring) 

however, everytime app launches found nil while unwrapping optional value suspect due first line of code force unwraps highscorestring.

i guess keychain not retain data after quits? tested without force unwrap instead did let if , highscore 0 because code not run. can 1 explain little why happens?


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -