title: Swift View Controller won't dismiss
body: <p>so I have a basic game going in Xcode. I started with Xcode's basic game template and built my game mostly inside the 'GameScene.swift'. When I finished with my game I wanted to add a start screen with a play button so I made a new UIViewController and added a button. I control click and dragged the button to the GameViewController and created a Modal Segue. I then wanted the game to go back when the player died. I tried various ways to dismiss the view but none worked. I am new to swift and really need help. Let me know what code/info is needed to find a solution. I have tried everything I have found on the internet. I thought I found a way around it by adding a button and Segue to the GameViewController to the menu but after multiple pushed it clogged the system and slowed to a crawl because none were dismissed. I can provide any code needed.</p>
  
  <p>Inside of GameViewController.swift in the GameViewController class I tried making a function that was called when the game ended. 
  I tried to both pop and dismiss the view controller. The function was called and a line printed to console but the view remained. The only thing printed to console is 'nil'</p>
  
  <pre><code>class GameViewController: UIViewController {
     func end(){
       print(navigationController?.viewControllers as Any)
       self.navigationController?.popViewController(animated: true)
       self.dismiss(animated: true, completion: nil)
     }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/oEcZJ.png" rel="nofollow noreferrer"> @ Vollan heres the pic</a></p>
  
  <p><a href="https://i.stack.imgur.com/CdIuT.png" rel="nofollow noreferrer">Here is the screenshot of the storyboard</a>.</p>
  
  <p>thanks in advance.</p>