title: How can I get the rootViewController of UINavigationController
body: <p>I want to get the rootViewController of UINavigationController. It works in Objective-c, but when I use it in Swift , the error reminds me that it was wrong.</p>
  
  <p><a href="https://i.stack.imgur.com/RUrJ3.png" rel="noreferrer">Code screenshot 1</a>.</p>
  
  <p>If I do this, add <code>as! NSArray</code>, it works, but also reminds me that "cast from '[UIViewController]' to unrelated type 'NSArray' always fails".</p>
  
  <p><a href="https://i.stack.imgur.com/THB3J.png" rel="noreferrer">Code screenshot 2</a></p>
  
  <p>Can somebody show a better way to get the `rootViewController`` without error. Thank you.</p>