title: Does 'pushViewController' Prevent the ViewController from Calling deinit?
body: <p>I have several view controllers (<code>UIViewController</code>).  <strong>Each view controller has its own <code>storyboard</code></strong>.  And I want the app to call <code>deinit</code> when it transitions from one view controller to another.  But it won't.</p>
  
  <p>The app starts with HomeViewController.  And it will transition to SelectViewController when the user taps a button (<code>UIButton</code>).</p>
  
  <pre><code>class HomeViewController: BasicViewController {
      @IBAction func selectTapped(_ sender: UIButton) {
          let storyboard = UIStoryboard(name:"Select",bundle:nil)
          let controller = storyboard.instantiateViewController(withIdentifier: "SelectView") as! UINavigationController
          let viewController = controller.topViewController as! SelectViewController
          self.navigationController?.pushViewController(viewController, animated: true)    
      }
  
      deinit {
          print("HOME HAS BEEN REMOVED FROM MEMORY")
      }
  }
  </code></pre>
  
  <p>The app never calls deinit when it leaves HomeViewController.  I wonder if that's because it's pushing a view controller?  If I set the view controller as follows, the app will crash.  What am I doing wrong?  I have never done it with different storyboards.  Thanks.</p>
  
  <pre><code>class HomeViewController: BasicViewController {
      @IBAction func selectTapped(_ sender: UIButton) {
          let storyboard = UIStoryboard(name:"Select",bundle:nil)
          let viewController = storyboard.instantiateViewController(withIdentifier: "SelectView") as! SelectViewController
          self.navigationController?.setViewControllers([viewController], animated: true)  
      }
  }
  </code></pre>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>I guess it's just the following.</p>
  
  <pre><code>@IBAction func selectTapped(_ sender: UIButton) {
      let storyboard = UIStoryboard(name:"Select",bundle:nil)
      let controller = storyboard.instantiateViewController(withIdentifier: "SelectView") as! UINavigationController
      self.present(controller, animated: true, completion: nil)
  }
  </code></pre>
  
  <p><strong>UPDATE 2</strong>
  I also clear the view controller stack when SelectViewController appears as follows.</p>
  
  <pre><code>override func viewWillAppear(_ animated:Bool) {
      super.viewWillAppear(animated)
  
      var navigationArray = self.navigationController?.viewControllers
      navigationArray?.removeAll()
  }
  </code></pre>