Swift   发布时间:2022-03-31  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了无法使用参数列表在Swift 2中调用“sendAsynchronousRequest”大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我目前正在重写部分 Swift 1.2代码,以便与 Swift 2.0兼容.实际上我无法弄清楚对“sendAsynchronousrequest”做了哪些更改 – 目前我的所有请求都失败了 NSURLConnection.sendAsynchronousrequest(request, queue: queue, completionHandler:{ (response: NSURLRespon
@H_673_10@
我目前正在重写部分 Swift 1.2代码,以便Swift 2.0兼容.实际上我无法弄清楚对“sendAsynchronousrequest”做了哪些更改 – 目前我的所有请求都失败了
NSURLConnection.sendAsynchronousrequest(request,queue: queue,completionHandler:{ (response: NSURLResponse!,data: NSData!,error: NSError!) -> Void in})

你有什么想法有什么不对吗?

@H_301_14@ 使用Swift 1.2和Xcode 6.3,sendAsynchronousrequest:queue:completionHandler:的签名是:
class func sendAsynchronousrequest(request: NSURLrequest,queue: NSOperationQueue!,completionHandler handler: (NSURLResponse!,NSError!) -> Void)

但是,对于Swift 2和Xcode 7 beta,sendAsynchronousrequest:queue:completionHandler:的签名已经更改,现在是:

// Note the non optionals,optionals and implicitly unwrapped optionals differences
class func sendAsynchronousrequest(request: NSURLrequest,completionHandler handler: (NSURLResponse?,NSData?,NSError?) -> Void)

因此,转向Swift 2和Xcode 7 beta,您将不得不更改completionHandler参数实现并确保您的队列参数是非可选的.

大佬总结

以上是大佬教程为你收集整理的无法使用参数列表在Swift 2中调用“sendAsynchronousRequest”全部内容,希望文章能够帮你解决无法使用参数列表在Swift 2中调用“sendAsynchronousRequest”所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。