2017-12-27 122 views
0

我已搜索有關此錯誤,我沒有找到有用的。 這裏是我的代碼: - 呼叫Alamofire - 額外參數'方法'在調用

@IBAction func btnSave(_ sender:UIButton) { 

    let teamName=txt1.text 
    let memberCount = txt2.text 

    let postParameters = "name="+teamName!+"&member="+memberCount!; 
    Alamofire.request(URL_SAVE_TEAM,method:.post, parameters: postParameters, encoding: JSONEncoding.default).responseJSON { response in 
      print(response.request as Any) // original URL request 
      print(response.response as Any) // URL response 
      print(response.result.value as Any) // result of response serialization 
    } 
} 

額外的參數「方法」我收到此錯誤

回答

1

我有過這樣的說法,它會正常工作。試試這個:

 let manager = Alamofire.SessionManager.default 

    manager.request(url, method: .post, parameters: param,headers: nil) 
     .responseJSON { response in 

      switch response.result { 
      case .success(_): 
       if let value = response.result.value 
       { } 
      } 
     } 
0

更改postParameters變量象下面這樣:

let postParamaters = ["name" : "teamName", "member" : "memberCount"]