title: Perform Segue from another class with helper function
body: <p>I have two classes, <code>ChargeCustomer</code> and <code>TwelvethViewController</code>. 
    In TwelvethViewController I have a <code>func goNextView()</code> which should perform a segue to next view controller when called. 
  <code>goNextView()</code> is called from <code>class ChargeCustomer</code> inside a Alamofire completion handler. 
  The problem is that this function  <code>goNextView()</code> is never called and I can't figure out why. 
  I tried to make it work based on this answer on stackoverflow <a href="https://stackoverflow.com/questions/28285517">Perform Segue From Another Swift File via a class function</a></p>
  
  <pre><code> class TwelvethViewController:UIViewController {
  
    //when this func is called, it should segue to Thiretheen
    func goNextView() {
      performSegue(withIdentifier: "twelvethToThiretheen", sender: self)
        }
   }
  
   class ChargeCustomer {
  
      //send a post request to the server
      Alamofire.request(urlString, method: .post, parameters: params, encoding: JSONEncoding.default, headers: ["Content-Type":"application/json"]).responseJSON {
          (response: DataResponse&lt;Any&gt;) in
                  print("received reply from ALamofire") //prints string
  
             //perform segue to Thireteen View Controller
          func showNextView(fromViewController:TwelvethViewController) {
                print("went through")      //doesn't print
                   fromViewController.goNextView()
                      print("it has segued")      //doesn't print
             }      
        } ///end of Alamofire
     } //end of chargeUsingCustomer
  </code></pre>
  
  <p><strong>Updated answer according to  José Neto</strong></p>
  
  <pre><code> class ChargeCustomer {
   //create instance of the viewcontroller that has segue with identifier    twelvethToThiretheen
     let twelvethVC = TwelvethViewController()
  
      //send a post request to the server
      Alamofire.request(urlString, method: .post, parameters: params, encoding: JSONEncoding.default, headers: ["Content-Type":"application/json"]).responseJSON {
          (response: DataResponse&lt;Any&gt;) in
                  print("received reply from ALamofire") //prints string
  
  //perform segue to Thirteen View Controller
     //crashes: &lt;CleaningApp.TwelvethViewController: 0x7fd4e16ad2a0&gt;) has no 
       //segue with identifier 'twelvethToThiretheen''
   self.showNextView(fromViewController: self.twelvethVC )
        } //end of Alamofire
  
      //perform segue to Thireteen View Controller
     func showNextView(fromViewController:TwelvethViewController) {
          fromViewController.goNextView()      
         }      
  } //end of chargeUsingCustomer
  </code></pre>