【发布时间】:2015-09-21 15:23:02
【问题描述】:
我在使用 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)")
}
}
}
【问题讨论】:
标签: http-post swift2 xcode7 alamofire