我目前正在重写部分
Swift 1.2代码,以便与
Swift 2.0兼容.实际上我无法弄清楚对“sendAsynchronousRequest”做了哪些更改 – 目前我的所有请求都失败了
NSURLConnection.sendAsynchronousRequest(request,queue: queue,completionHandler:{ (response: NSURLResponse!,data: NSData!,error: NSError!) -> Void in})
Cannot invoke ‘sendAsynchronousRequest’ with an argument list of type
‘(NSURLRequest,queue: NSOperationQueue,completionHandler:
(NSURLResponse!,NSData!,NSError!) -> Void)’
你有什么想法有什么不对吗?
使用Swift 1.2和Xcode 6.3,sendAsynchronousRequest:queue:completionHandler:的签名是:
原文链接:https://www.f2er.com/swift/318920.htmlclass 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参数实现并确保您的队列参数是非可选的.