yetelday
yetelday

Reputation: 1

Type of expression is ambiguous without more context" error with Alamofire

I'm having a "Type of expression is ambiguous without more context" error with Alamofire and I have no idea how to get out of this, HELP ! :) I copied the POST request from the gitHub documentation. I'm with Xcode7

import UIKit
class LoginViewController: UIViewController {

@IBOutlet weak var emailTF: UITextField!
@IBOutlet weak var motDePasseTF: UITextField!
@IBOutlet weak var btnConnexion: UIButton!
@IBOutlet weak var resterConnec: UISwitch!

override func viewDidLoad() {
    super.viewDidLoad()


    // Do any additional setup after loading the view.
    btnConnexion.layer.cornerRadius = 50
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


@IBAction func btnConnexion(sender: UIButton) {

    //verif champs vides
    if (emailTF.text!.isEmpty || motDePasseTF.text!.isEmpty)
    {
        let alerte = afficheAlerte("Tous les champs sont nécessaires")
        self.presentViewController(alerte, animated: true, completion: nil)
        return
    }




    //paramètres JSON
    let reqParams = ["user": [
                            "email": emailTF.text!.lowercaseString,
                            "password": motDePasseTF.text
                            ]
                    ]

    request(.POST, "https://bakkbone.com/api/v1/users/login", parameters: reqParams, encoding: .JSON)
            .responseJSON { _, _, result in
            print(result)
            debugPrint(result)

            print("Parsed JSON: \(result.value)")
    }
 }
}

Upvotes: 0

Views: 2099

Answers (1)

Alex Christodoulou
Alex Christodoulou

Reputation: 2963

It's because of the parameters. You need to put an "!" at the end of "password": motDePasseTF.text

make it

"password": motDePasseTF.text!

Upvotes: 2

Related Questions