title: How to push and present to UIViewController programmatically From a XIB in iOS Swift 3
body: <p>Im working on a project in swift 3.0 and I use the following mechanism to navigate from one UIViewController to another.  </p>
  
  <pre><code>if let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MP3ViewController") as? MP3ViewController {
    viewController.mediaDetails = mp3Details
    if let navigator = navigationController {
        navigator.pushViewController(viewController, animated: true)
    }
  }
  </code></pre>
  
  <p>However when I try the same mechanism in the XIB file it gives me an error </p>
  
  <blockquote>
    <p><strong>Error:</strong> saying 'use of unresolved identifier navigationController'</p>
  </blockquote>
  
  <p><strong>How can I create a navigationController instance here ?</strong> bellow Ive shown the code of my XIB class that gives me an error </p>
  
  <pre><code>if let categoriesController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "CategoriesViewController") as? CategoriesViewController {
    categoriesController.categoryName = trimmedCategortyNameText
  
    if let navigator = navigationController {
        navigator.pushViewController(categoriesController, animated: true)
    }
  }
  </code></pre>