无法使用类型的参数列表调用dataTaskWithRequest [英] Cannot invoke dataTaskWithRequest with an argument list of type

查看:1267
本文介绍了无法使用类型的参数列表调用dataTaskWithRequest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的iOS Swift应用程序中有一个奇怪的错误。编译器在第一行提交:

I get a weird error in my iOS swift app. The compiler complains at the first row of:

let task = session.dataTaskWithRequest(request) { data, response, error in
    self.oauthManager.customOAuth2Manager.parseData(data, response: response, error: error, body:request, callback: { (jsonArray, error) -> Void in
    })
}

编译器错误是:

Cannot invoke 'dataTaskWithRequest' with an argument list of type '(NSURLRequest, (_, _, _) -> _)'

但是,它不在该行似乎错误的位置。如果我删除对 parseData 的内部调用,则不会出现错误。

However, it's not on that row the error seems to be located. If I remove the inner call to parseData the error does not appear.

声明为 parseData is:

func parseData(data: NSData, response:NSURLResponse, error:NSError?, body:String?, callback:JsonRequestCallback)

其中 JsonRequestCallback 是:

public typealias JsonRequestCallback = (jsonArray: NSArray?, error: NSError?) -> Void

另外:

let request = oauthManager.newLoginRequest(emailOrCompanyCode: emailOrCompanyCode, password: password) as NSURLRequest
let session = NSURLSession.sharedSession()

func newLoginRequest(var #emailOrCompanyCode: String, var password:String?) -> NSMutableURLRequest

任何想法?

推荐答案

为了回答我自己的问题,Satachito是正确的。只是一个无效的参数。不幸的是Swift编译器没有指定确切的错误,而不是正确的行。

To answer my own question, Satachito was correct. Just an invalid parameter. Unfortunately the Swift compiler does not specify the exact error, not the correct line for this.

因此,对于有类似问题的其他人,请在任何传递的封闭中查找所有代码中的错误

So for others having similar issues, look for misstakes in all code in any passed closures

这篇关于无法使用类型的参数列表调用dataTaskWithRequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆