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

前端之家收集整理的这篇文章主要介绍了闭包错误-Cannot invoke 'responseResult' with an argument list of type前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. func login(mobile:String,passwd:String,responseResult:(result:NSDictionary?,error:(Int8,String)?)->Void) {
  2. Alamofire.request(.GET,"http://httpbin.org/get",parameters: ["foo": "bar"])
  3. .responseString { (request,response,string,error) in
  4. if error != nil {
  5. responseResult(result: nil,error: (error!.code,error!.localizedDescription))
  6. } else {
  7. responseResult(result: nil,error: nil)
  8. }
  9. }
  10. }
  11. >>>Cannot invoke 'responseResult' with an argument list of type '(result: nil,error: (Int,String))'

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

修改方法

  1. func login(mobile:String,passwd:String,responseResult:(result:NSDictionary?,error:(Int,String)?)->Void)

猜你在找的Swift相关文章