It has confused itself, you can help, I try to transfer a variable from one scene to another, everything seems to be doing everything right, but I can't pass it https://yadi.sk/d/5a0z5_1_udACZ
2 answers
you ship it in the menu, but you don’t save it anywhere
NSUserDefaults.standardUserDefaults().setInteger(score, forKey: "score")
- Exactly, that's what I forgot, thanks for the help) - Leci
- you are an amazing person :) - Max Mikheyenko
- And it happens = D - Leci
|
Use the method: prepareForSegue
. Like that:
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) { if (segue.identifier == "YourSceneId") { var newController = segue!.destinationViewController as secondScene; newController.variableName = newValue } }
A lesson on the topic here .
- I have a SpriteKit - Leci
- stackoverflow.com/a/18924419/608343 - Vitali Eller
|