我目前正在重写部分Swift 1.2代码,以便与Swift 2.0兼容.实际上我无法弄清楚对"sendAsynchronousRequest"做了哪些更改 - 目前我的所有请求都失败了
NSURLConnection.sendAsynchronousRequest(request, queue: queue, completionHandler:{ (response: NSURLResponse!, data: NSData!, error: NSError!) -> Void in})
Run Code Online (Sandbox Code Playgroud)
无法使用类型'的参数列表调用'sendAsynchronousRequest'(NSURLRequest,queue:NSOperationQueue,completionHandler:(NSURLResponse!,NSData!,NSError!) - > Void)'
你有什么想法有什么不对吗?
使用Swift 1.2和Xcode 6.3,签名sendAsynchronousRequest:queue:completionHandler:是:
class func sendAsynchronousRequest(request: NSURLRequest,
queue: NSOperationQueue!,
completionHandler handler: (NSURLResponse!, NSData!, NSError!) -> Void)
Run Code Online (Sandbox Code Playgroud)
但是,使用Swift 2和Xcode 7 beta,签名sendAsynchronousRequest:queue:completionHandler:已经改变,现在是:
// Note the non optionals, optionals and implicitly unwrapped optionals differences
class func sendAsynchronousRequest(request: NSURLRequest,
queue: NSOperationQueue,
completionHandler handler: (NSURLResponse?, NSData?, NSError?) -> Void)
Run Code Online (Sandbox Code Playgroud)
因此,转向Swift 2和Xcode 7 beta,您将不得不更改completionHandler参数实现并确保您的queue参数是非可选参数.
| 归档时间: |
|
| 查看次数: |
6004 次 |
| 最近记录: |