ios - using NSUserDefaults to display score -
i using nsuserdefaults display score gamescene
on resetviewcontroller
. problem if user doesn't score display players last score.
in gamescene
var score: int = 0 var scorelabel = sklabelnode() let defaults = nsuserdefaults.standarduserdefaults() score++ scorelabel.text = "\(score)" defaults.setobject(scorelabel.text, forkey: "scoring")
in resetviewcontroller
var score = defaults().stringforkey("scoring") yourscore.text = score
i'm sure it's simple can't seem figure out
when need score reset, call
nsuserdefaults.standarduserdefaults().setobject(nil, forkey: "scoring")
Comments
Post a Comment