[Solved] Swift 3 code update


I fixed your code using Swift 3 syntax.

class SignUp: UIViewController {

@IBOutlet weak var buttonNameTxt: UITextField!
@IBOutlet weak var buttonEmailTxt: UITextField!
@IBOutlet weak var buttonPwdTxt: UITextField!

override func viewDidLoad() {
    super.viewDidLoad()
}

@IBAction func buttonSignIn(_ sender: UIButton) {

    let usermainname = buttonNameTxt.text!
    let username = buttonEmailTxt.text!
    let password = buttonPwdTxt.text!

    let myURL = URL(string: "https://mev.com/api/login")
    let request = NSMutableURLRequest(url: myURL!)
    request.httpMethod = "Post"

    let postString = "name = \(usermainname) email = \(username) &passwod = \(password)"
    request.httpBody = postString.data(using: String.Encoding.utf8)

    let task = URLSession.shared.dataTask(with: request as URLRequest) { data , response , error in

        do {
            if let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary {

                let resultValue = json["status"] as? String
                print("result: \(resultValue)")

                if resultValue == "success", let messageToDisplay = json["massage"] as? String {
                    print("\(messageToDisplay)")
                }
            }

        } catch {

            print("error")
        }
    }
    task.resume()
}
}

3

solved Swift 3 code update