当我尝试在 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/