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

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -