I have a problem with NSUserDefaults.
I followed Steve's answer from this one: Saving highscores with NSUserDefaults
And now, I have a problem. When my GameScene is to be over, and just before the transfer to the GameOverScene is initialized, I do this:
if scene.score > Score.highScore {
var defaults = NSUserDefaults()
defaults.setInteger(scene.score, forKey: "highScore")
println("score1, highscore1")
println(scene.score)
println(Score.highScore)
}
And you can see I compare the gameScene score to the highscore, and then set the highscore's Integer to the scene's one, that player achieved. Yet, program print's out the current score correctly, leaving the highScore the same, at 0. Before I tried to do:
Score.HighScore = scene.score // changing Score.HighScore to the scene.score manually.
Unfortunately, did not work. Here's the full HighScore Class, that handles saving and retrieving highscore: http://pastebin.com/dz3b3WAk
Any help appreciated.
EDIT: or maybe, someone is aware of easier solution of saving something to NSUserDefaults, without all that complication?