现在,我使用Alamofire最新版本4.7.3,并使用swift 4.1,我收到错误获取Extra参数,我不知道发生了什么事情
func serviceHandling(){
let url : String = "http://1.1.11.15:8080/f/api/getLoginDetails"
var params: NSDictionary = ["userName" : "test1234" , "password":"test1234" ,"gcmRegistrationId":"test","deviceType":"iPhone"]
Alamofire.request(url, method: .post, parameters: params, encoding: JSONEncoding.default, headers: nil).responseJSON
{ (response:DataResponse<Any>) in
}
}
答案 0 :(得分:1)
您已在此行将params
声明为NSDictionary
var params: NSDictionary = ["userName" : "test1234" , "password":"test1234" ,"gcmRegistrationId":"test","deviceType":"iPhone"]
Alamofire请求要求使用Parameter
类型的参数,而实际上是[String: Any]
类型的参数。您要做的就是用这种类型声明您的参数
var params: [String: Any] = ["userName" : "test1234" , "password":"test1234" ,"gcmRegistrationId":"test","deviceType":"iPhone"]