title: How to programmatically pop a view controller and present a new one
body: <p>What I am trying to do is present a viewController and when the user touches a button I want to call popViewController and then present a different viewController.  But I cannot figure out how to do it.</p>
  
  <p>Some of the things I have tried are call pop and then immediately call present, call present after a delay, pup the pop with a completion block and then in the completion block call present, as well as other ideas.</p>
  
  <p>I think I am over complicating the whole thing, i believe their should be an easy way to do this.</p>
  
  <p>Thanks for any help with this.</p>
  
  <p>CLARIFICATION:</p>
  
  <p>I do this on a touch:</p>
  
  <pre><code>        if let vc = UIStoryboard(name: "Listing", bundle: nil).instantiateInitialViewController() as? ListingViewController
      {
          vc.listing = listing
          vc.editListing = forEdit
          vc.title = " "
          self.navigationController?.pushViewController(vc, animated: true)
      }
  </code></pre>
  
  <p>From that VC when the user touches a button I do this:</p>
  
  <pre><code>self.navigationController?.popViewController(animated: true)
  </code></pre>
  
  <p>When the VC goes away I want to do something like this:</p>
  
  <pre><code>        if let vc = UIStoryboard(name: "CreateListing", bundle: nil).instantiateInitialViewController() as? NewCreateListingViewController
      {
          vc.bMakeSimiliar = makeSimiliar
          vc.listing = listing
          vc.editListing = editListing
          vc.title = " "
          self.navigationController?.pushViewController(vc, animated: true)
      }
  </code></pre>
  
  <p>Basically my user is viewing the first controller which is a listing, from the listing VC he touches a button to add a new listing, so I want to dismiss the listing view controller and present him with the create listing view controller.</p>
  
  <p>When I execute the above code to present the new VC nothing happens.  I am doing this immediately after the popViewController.</p>