【发布时间】:2015-09-28 15:28:20
【问题描述】:
我正在 Swift 2.0 上迁移我的应用程序。我也借此机会将 Alamofire 从 1.3 迁移到 2.0。
但是现在我的应用程序不再工作了,而且我在使用 Alamofire 的文件上出现了很多错误。
首先在我的枚举路由器声明中,我得到一个错误提示
private enum Router: URLRequestConvertible {
编辑:这是实现方法的开始
URLRequestConvertible
// MARK: URLRequestConvertible
var URLRequest: NSURLRequest {
let URL = Router.baseURL.URLByAppendingPathComponent(self.path)
let URLRequest = NSMutableURLRequest(URL: URL)
URLRequest.HTTPMethod = self.method.rawValue
switch self {
case .Login(let email, let password):
return self.encoding.encode(URLRequest, parameters: [
"email": email,
"password": password]).0
case .Logout:
return self.encoding.encode(URLRequest, parameters: nil).0
}
类型“Router”不符合协议“URLRequestConvertible”
当我要检查 .responseJSON { (_, _, json, error) in 时,我的所有请求中的第二个我收到了一个错误提示
元组类型 '(NSURLRequest?, NSHTTPURLResponse?, Result)' (又名 '(Optional, Optional, Result)') 和 '(_, _, _, _)' 有不同的 元素数量(3 对 4)
编辑:好的,不再error field,但是你是如何处理错误的呢?
EDIT2:好的,现在您需要为结果使用开关。谢谢
以前没有的错误
感谢您的帮助!
【问题讨论】:
-
发布你的
Router类代码,只发布实现URLRequestConvertible协议的方法。
标签: ios swift swift2 alamofire