title: How do I pass JSON data between controller in Swift 3.0?
body: <p>I have these JSON data:</p>
  
  <pre><code>{"login":"ET001","email":"email@try.com"}
  </code></pre>
  
  <p>In Swift 3.0, I created two files which are LoginVC and ViewController.</p>
  
  <p>ViewController can only be accessed after LoginVC verified the credentials. So far I managed to make the login access the ViewController page based on "success" JSON data from database.</p>
  
  <p>But my next goal is to <strong>pass the JSON data "[login]" from LoginVC into ViewController</strong>.</p>
  
  <p>In ViewController, I created <strong>UILabel "loginLbl"</strong> to display the JSON value from LoginVC.</p>
  
  <p>How do update my code?</p>
  
  <h3>LoginVC.swift</h3>
  
  <pre><code>import UIKit
  class LoginVC: UIViewController {
  
      @IBOutlet var _login: UITextField!
      @IBOutlet var _pass: UITextField!
      @IBOutlet var outputLbl: UILabel!
  
      var login: String!
      var pass: String!
  
      override func viewDidLoad() {super.viewDidLoad()}
  
  override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
      if segue.identifier == "tocey"{
          if let destination = segue.destination as? ViewController {
              destination.passedData = self.outputLbl.text
              print("Sender value is : \(sender)")
          }
      }
  }
  
  @IBAction func loginData(_ sender: Any) {
  
      login = _login.text
      pass  = _pass.text
  
      if(login == "" || pass == "") {
  
          return
      }
      else {
          let url             = URL(string: "http://localhost/login.php")
          let session         = URLSession.shared
  
          let request         = NSMutableURLRequest(url: url! as URL)
          request.httpMethod  = "POST"
  
          let paramToLogin    = "login=\(login!)&amp;pass=\(pass!)"
          request.httpBody    = paramToLogin.data(using: String.Encoding.utf8)
  
          let task = session.dataTask(with: request as URLRequest, completionHandler: {
              (data, response, error) in
              if error != nil {
                  return
              }
              else {
                  do {
                      if let json = try JSONSerialization.jsonObject(with: data!) as? [String: String] {
                          DispatchQueue.main.async {
                              let success  = Int(json["success"]!)
                              let loginvaluefromdb = json["login"]
                              if(success == 1){
                                      self.outputLbl.text = loginvaluefromdb;
  
                                      let abc = json["login"]
                                      self.performSegue(withIdentifier: "tocey", sender: abc)
                                      return
                                  }
                              }
                          }
                      }
                      catch {
                      }
                  }
              })
              task.resume()
          }
      }
  }
  </code></pre>
  
  <h3>ViewController.swift</h3>
  
  <pre><code>import UIKit
  class ViewController: UIViewController {
      @IBOutlet var loginLbl: UILabel!
  
      var passedData: String!
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          loginLbl.text = passedData
      }
  }
  </code></pre>
  
  <p>How to pass it into <strong>UILabel loginLbl</strong>?</p>