表达的类型是模糊的,没有更多的上下文“与Alamofire的错误

时间:2015-09-21 15:23:02

标签: http-post swift2 xcode7 alamofire

我有一个“表达的类型是模糊的,没有更多上下文”错误与Alamofire,我不知道如何摆脱这个,帮助! :) 我从gitHub文档中复制了POST请求。 我正在使用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)")
    }
 }
}

1 个答案:

答案 0 :(得分:2)

这是因为参数。你需要放一个“!”在“密码”的末尾:motDePasseTF.text

制作

"password": motDePasseTF.text!