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

  • which one? where to look? - Max Mikheyenko
  • Variable score from GameScene to Menu - Leci

2 answers 2

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 .