ios - Alamofire v4 额外参数方法调用错误

标签 ios swift xcode alamofire

更新到 alamofire 版本 4 后,出现错误:extra argument method in call

Alamofire.request("www.blabla", method: .put, parameters: parameters, headers: headers, encoding: .JSON)

我已经像上面那样将其更改为使用“方法:.put”,但我仍然收到错误

最佳答案

我在升级到 Alamofire 4 时遇到了这个问题,并通过移动 header 参数并将其作为调用中的最后一个参数来解决它。另外 encoding: .JSON 应该是 encoding: JSONEncoding.default

调用应该是这样的:

Alamofire.request(url: myUrl, method: .put, parameters: myParams,
     encoding: JSONEncoding.default, headers: myHeaders)

关于ios - Alamofire v4 额外参数方法调用错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39834060/

相关文章:

objective-c - UIPanRecognizer 不起作用。我的观点从未重绘

ios - 持续扫描 iOS CoreBluetooth Central Manager?

ios - 如何更改谷歌地图 SDK iOS 上动态标记的坐标?

macos - 在 OSX 中设置多行标签的高度

swift - 如何强制 View Controller 在 macOS 中使用明暗模式?

ios - 无法将数据获取到 MasterViewController 中的 UITableView 中

iphone - 为什么 Xcode 编译器没有警告我部署目标的无效方法?

ios - 一个面向其他普遍面向的应用程序如何强制启动肖像?

iphone - 使用键盘后,Xcode 模拟器键盘不出现

ios - 加载 .xib 文件时 Cocoapod 编译失败