ios - 将对象设置为参数时调用错误中的额外参数 'method'

标签 ios swift alamofire

当我尝试在 Alamofire 中设置 SessionConductBean 的对象时,出现Extra argument 'method' in call 错误。

let param = [SessionConductBean(billId: self.SessionListArray[0].billId, memberId: self.SessionListArray[0].memberId)]

     Alamofire.request(URL2, method: .get, parameters: param).debugLog().responseJSON { response in

                print("Success:Session: \(response.result.isSuccess)")
                print("Result...\(String(describing: response.value))")

                if(response.result.isSuccess) {
                    if(response.value != nil){

                    }
                }
                if(response.result.isFailure){
                    print("Failure\(response.result.isFailure)")
                }


            }

最佳答案

这是已知问题。你应该检查你通过了什么。 来自 GitHub 的引用:

Any time one argument is of the wrong type, the Swift interpreter here believes that you're wrongly using request(urlRequest:URLRequestConvertible) and therefore believes there's an extra method: argument.

https://github.com/Alamofire/Alamofire/issues/1508

所以一定要传递正确的url。 这也可能是 ParameterEncoding 问题。

尝试以下操作:

Alamofire.request(URL2, method: .get,
                    parameters: param, 
                      encoding: URLEncoding.default, 
                       headers: nil)

关于ios - 将对象设置为参数时调用错误中的额外参数 'method',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46888647/

相关文章:

ios - 如何固定在 iOS 版谷歌地图上?

ios - ios中使用tag动态生成并访问UITextField

swift - 当我更改字距调整时,UITextView 样式会重置

json - Alamofire 4.4 序列化失败,内容类型问题

ios - 使用 "pop-up"VC 时,背景模糊效果不起作用,没有明显的原因

ios - fatal error : unexpectedly found nil while unwrapping an Optional value while retrieving default

swift - 以编程方式在 ScrollView 中获取 UIImageView 时遇到问题

swift - Alamofire Xcode 8 GM,缺少Mashape应用程序 key

ios - 有没有办法通过 Alamofire 上传 doc、pdf 文件?

iOS - 设置值 :forUndefinedKey problem on a subView