[Solved] Reduce UserDefaults Integer Value – Swift


First, obtain the old value of the high score. Then, do the arithmetic before finally saving the new value:

let oldValue = UserDefaults.standard.integer(forKey: "HIGHSCORE")
let newValue = oldValue - 20

UserDefaults.standard.set(newValue, forKey: "HIGHSCORE")

solved Reduce UserDefaults Integer Value – Swift