闭包错误-Cannot invoke 'responseResult' with an
发布时间:2020-12-14 02:02:56 所属栏目:百科 来源:网络整理
导读: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 , er
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)
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |