所以我试图用Alamofire发送一个json对象作为参数.我想我已经在他们的文档中遵循了示例,但是我在方法调用中遇到了这个错误.
@IBAction func saveButton(sender: AnyObject) { var url = "http://b857aaa4.ngrok.io/recruit" let parameters = [ "_id" : firstNameTextField.text,"alt_email" : "","forename" : firstNameTextField.text,"phone" : recruteePhone.text,"recruiter" : [ "comments" : "",//TODO comments "date_met" : "",//TODO tdoays date "email" : "",//TODO recruiter email "event_name" : ""//TODO event name ],"surname" : lastNameTextField.text ] Alamofire.request(.PUT,url,parameters: parameters,encoding: .JSON) .responseJSON { (req,res,json,error) in if(error != nil) { NSLog("Error: \(error)\n") } else { var json = JSON(json!); println("success"); } }
解决方法
将参数声明为
let parameters: [String: AnyObject] = [
它编译好了.