title: Swift 4 - How to set and show a new root view controller from current view controller
body: <p>Struggling a couple of days with this...</p>
  
  <p>I have set a <code>rootVC</code> from <code>AppDelegate</code> in <code>didFinishLaunchingWithOptions</code> and this is working fine.</p>
  
  <p>Now from that <code>rootVC</code> I want that, if some condition is met, eg. <code>if x=y</code> a new <code>rootVC</code> is set and displayed.</p>
  
  <p>I stack overflowed long long time, found different solutions, but none is working.</p>
  
  <p>The below is compiling, and executing, I checked with breakpoint, but nothing shows up in the app.</p>
  
  <pre><code>animated    Bool    false   
  self    Regional2.IrelandViewController 0x0000000102b0ff30
  newViewController   Regional2.IrelandMain   0x0000000102d0d300
  customViewControllersArray  NSArray 0x00000001c000b620
  ObjectiveC.NSObject NSObject    
  Exception State Registers       
  far unsigned long   0x00000001b0a7ba78
  esr unsigned int    0x92000007
  exception   unsigned int    0x00000000
  Floating Point Registers        
  General Purpose Registers       
  </code></pre>
  
  <p>and the piece of the code . . .</p>
  
  <pre><code>override func viewDidAppear(_ animated: Bool) {
      super.viewDidAppear(animated)
  
      let newViewController = self.storyboard?.instantiateViewController(withIdentifier: "IrelandMain") as! IrelandMain
  
      let customViewControllersArray : NSArray = [newViewController]
  
      self.navigationController?.viewControllers = customViewControllersArray as! [UIViewController]
      self.navigationController?.pushViewController(newViewController, animated: true)
  </code></pre>
  
  <p>}</p>
  
  <p>Please notice that <code>navigationController</code> show produces the same output. Nothing changes.</p>