Cannot invoke dataTaskWithRequest with an argument list of type

∥☆過路亽.° 提交于 2019-12-11 08:47:26

问题


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
    })
}

The compiler error is:

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

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.

The declaration to parseData is:

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

where JsonRequestCallback is:

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

Also:

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

and

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

Any ideas?


回答1:


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



来源:https://stackoverflow.com/questions/30103902/cannot-invoke-datataskwithrequest-with-an-argument-list-of-type

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!