title: how to work with conditional segue
body: <p>i have been trying to implement condition segues depending on particular conditions, but i don't know where i am lagging behind.If anyone can help me it would be more than a thankful
  below is the code:-
  There are two segues which have to be handled, <code>segueOtp</code>&amp; <code>segueError</code></p>
  
  <pre><code> @IBAction func btnToOtpScreen(_ sender: Any) {
  
          let providedMarketingRef = txtMarketingRef.text
          //let providedhopName = txtShopName.text
  
          if((providedMarketingRef?.isEmpty)!)
          {
              displayAlertMessage(messageToDisplay: "Enter Your Marketing Reference")
  
          }
  
          else
          {
  
              let myUrl = URL(string: "http://kumbhkaran.co.in/ios_otp_check/request_sms.php");
  
              //let myUrl = URL(string: "http://kumbhkaran.co.in/OTPCheck/request_sms.php");
              var request = URLRequest(url:myUrl!);
              request.httpMethod = "POST";
  
              let postString = "email=\(Email)&amp;mobile=\(UserName)&amp;name=\(ShopName)"
  
              request.httpBody = postString.data(using: String.Encoding.utf8);
  
              let task = URLSession.shared.dataTask(with: request) { (data: Data?, response: URLResponse?, error: Error?) in
  
                  DispatchQueue.main.async
                      {
  
                          //spinningActivity!.hide(true)
  
                          if error != nil {
                              self.displayAlertMessage(messageToDisplay: error!.localizedDescription)
                              return
                          }
  
                          do {
                              let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary
  
                              if let parseJSON = json {
  
                                  var msg : String!
  
                                  //getting json response
                                  msg = parseJSON["message"] as! String?
  
                                  print(msg)
  
                          if(msg == "SMS request is initiated! You will be receiving it shortly.")
                            {
  
                              //self.performSegue(withIdentifier: "segueOTP", sender: self)
  
                              self.GlobalSegue="segueOTP"
                             }
                               else if(msg == "Sorry! Error occurred in registration.")
                              {
                                  //self.performSegue(withIdentifier: "segueError", sender: self)
                               self.GlobalSegue="segueError"
                              }
  
                              else if(msg == "Mobile number already existed!")
                             {
                              //self.performSegue(withIdentifier: "segueError", sender: self)
                             self.GlobalSegue="segueError"
                              }
                               else if(msg == "Sorry! mobile number is not valid or missing.")
                              {
                                  //self.performSegue(withIdentifier: "segueError", sender: self)
                                 self.GlobalSegue="segueError"
                              }
  
  
                              }
                          } catch{
                              print(error)
                          }
  
  
  
                  }
  
              }
  
              task.resume()
  
  
          }
  
      }
  
  override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  
      if (GlobalSegue=="segueOTP")
      {
      let destViewController : OTPScreen = segue.destination as! OTPScreen
      destViewController.Category = Category
      destViewController.SubCategory = SubCategory
      destViewController.ShopName = ShopName
      destViewController.ManagerName = ManagerName
      destViewController.ManagerMobile = ManagerMobile
      destViewController.UserName = UserName
      destViewController.Landline = Landline
      destViewController.Email = Email
      destViewController.Website = Website
      destViewController.City = City
      destViewController.Address = Address
      destViewController.Area = Area
      destViewController.Pincode = Pincode
      destViewController.StartTime = StartTime
      destViewController.EndTime = EndTime
      destViewController.ShopStatus = ShopStatus
      destViewController.HomeDelivery = HomeConsultancy
      destViewController.Password = Password
      destViewController.MarketingRef = txtMarketingRef.text!
     destViewController.ImgShopName = ShopName
      destViewController.OtherCategory = Other
      destViewController.WorkerCount = WorkerCount
      destViewController.latitude = lblLatitude.text!
      destViewController.longitude = lblLongitude.text!
  }
      else
      {
          var _ : ErrorController = segue.destination as! ErrorController
      }
  </code></pre>
  
  <p>}
  //ErrorController and Congratulations are two different views where i want to divert based on the conditions.</p>