title: Does anyone know why my app crashes when I switch scenes?
body: <p>I´m new to coding and I created a game with two scenes(Game Scene and Main menu) with Sprite-Kit. I have a Home Button which switches back to the Main Menu Scene from the Game Scene. When I tapp on the Home Button the app crashes and I wasn´t able to find a solution yet.</p>
  
  <p>Here is the error(occurs while running touchesEnded()):</p>
  
  <pre><code>    libc++abi.dylib: terminating with uncaught exception of type NSException
  
      libsystem_kernel.dylib`__pthread_kill:
      0x112417d38 &lt;+0&gt;:  movl   $0x2000148, %eax          ; imm = 0x2000148 
      0x112417d3d &lt;+5&gt;:  movq   %rcx, %r10
      0x112417d40 &lt;+8&gt;:  syscall 
  -&gt;  0x112417d42 &lt;+10&gt;: jae    0x112417d4c               ; &lt;+20&gt;
      0x112417d44 &lt;+12&gt;: movq   %rax, %rdi
      0x112417d47 &lt;+15&gt;: jmp    0x112410caf               ; cerror_nocancel
      0x112417d4c &lt;+20&gt;: retq   
      0x112417d4d &lt;+21&gt;: nop    
      0x112417d4e &lt;+22&gt;: nop    
      0x112417d4f &lt;+23&gt;: nop   
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>var homeButton = SKSpriteNode(imageNamed: "HomeButton5.0")
  
  class GameScene{
  
     override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
  
       for touch in touches{
  
         let locationUser = touch.location(in: self)
  
       if atPoint(locationUser) == homeButton {
  
        }
      }
    }
  
    override func touchesEnded(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
  
      for touch in touches{
  
        let locationUser = touch.location(in: self)
  
         if atPoint(locationUser) == homeButton { // &lt;-- error/ crash 
  
  
          let transition = SKTransition.crossFade(withDuration: 0.2)
          let mainMenu = Mainmenu(size: self.size)  
  
          self.view?.presentScene(mainMenu, transition: transition) //transition
         }
       }
     }
   }
  
  
  class Mainmenu: SKScene{  //Scene to switch to
  
  }
  </code></pre>
  
  <p>Console:
  <a href="https://i.stack.imgur.com/vZfsM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vZfsM.png" alt="enter image description here"></a></p>