title: Programmatically go back to consecutive 3rd previous ViewController in Swift
body: <p>I have seen too much threads on how to go back to previous View controller, that makes sens and are easy also to implement. But in my case there is only one type of complication. Consider the following situation. </p>
  
  <ul>
  <li><strong>VC1 --Opens--> VC2:</strong> vc2 is a viewcontroller that is showing a Form. On correct filling the user is taken to another VC. call it vC3 </li>
  <li><p><strong>VC2 --Opens--> VC3:</strong> vc3 is a view controller that takes swipe card information and if the information provided is correct it takes to VC4 </p></li>
  <li><p><strong>VC3 --Opens--> VC4:</strong>.  </p></li>
  </ul>
  
  <blockquote>
    <p>VC4 is the viewcontroller that loads up all user contacts and send
    information/data to that selected contact. SO far it is fine. now
    there is 2 conditions, if the data that I send is correctly sent then
    I have to go back to VC1 directly, and if the data is not sent then I
    have to go back to vc2 directly to take up information again.</p>
  </blockquote>
  
  <p>so what are the best thing to handle this situation. Please suggest. </p>
  
  <p><strong>UPDATE:</strong></p>
  
  <blockquote>
    <p>I am using Tab bar controller, in that controller under one of that View , I am opening other VIew controller from this in series. Like from this Opening VC2 that opens VC3 and so on...</p>
  </blockquote>
  
  <p><strong>This is how I am showing my ViewController 2</strong> </p>
  
  <pre><code>let myVC2 = self.storyboard?.instantiateViewController(withIdentifier: "idMyVC2") as MyVC2 
  myVC2.modalPresentationStyle = .fullScreen 
  self.present(myVC2,animated : true) 
  </code></pre>