I am trying to save a \"highScore\" integer that persists after the app is closed using SpriteKit.
That\'s it. Just one single integer on one single screen that I will e
You can use UserDefaults
class for that purpose.
If you have any sort of GameManager
singleton, you can define a computed variable which saves and reads from UserDefaults
:
var highScore: Int {
get {
return UserDefaults.standard.integer(forKey: "highScore")
}
set {
UserDefaults.standard.set(newValue, forKey: "highScore")
}
}