闭包错误-Cannot invoke 'responseResult' with an argument list of type

来源:互联网 发布:雪梨淘宝店叫什么名字 编辑:程序博客网 时间:2024/05/20 11:21
func login(mobile:String, passwd:String, responseResult:(result:NSDictionary?,error:(Int8, String)?)->Void) {        Alamofire.request(.GET, "http://httpbin.org/get", parameters: ["foo": "bar"])            .responseString { (request, response, string, error) in                if error != nil {                    responseResult(result: nil, error: (error!.code, error!.localizedDescription))                } else {                    responseResult(result: nil, error: nil)                }        }   }   >>>Cannot invoke 'responseResult' with an argument list of type '(result: nil, error: (Int, String))'

这个错误的原因是error!.code是int类型,而声名的是int8类型

修改方法:

func login(mobile:String, passwd:String, responseResult:(result:NSDictionary?,error:(Int, String)?)->Void) 
0 0
原创粉丝点击