无法使用类型的参数列表调用dataTaskWithRequest

编程入门 行业动态 更新时间:2024-10-28 03:30:41
本文介绍了无法使用类型的参数列表调用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

本文发布于:2023-11-26 16:34:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634395.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:参数   类型   列表   dataTaskWithRequest

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!