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

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) 

你可能感兴趣的:(坑爹的Swift)