[swift-users] Cannot implement NSURLSessionDownloadDelegate

Sebastian Hagedorn sebastian at iosphere.de
Tue Mar 22 10:49:01 CDT 2016


I have started migrating a Swift 2.2 project to Swift 3.0 using the latest dev snapshot (16 March 2016) and Xcode 7.3.

I have an existing class (and have verified the same behaviour in a new, isolated test project) that declares to conform to NSURLSessionDownloadDelegate (and inherits from NSObject). However, I cannot satisfy the compiler as I get the following error:

> .../SessionDel.swift:11:7: Type 'MyDelegate' does not conform to protocol 'NSURLSessionDownloadDelegate'
> 
> .../Foundation.NSURLSessionDownloadDelegate:3:17: Protocol requires function 'urlSession(_:downloadTask:didFinishDownloadingTo:)' with type '(NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingTo: NSURL) -> Void’
> 
> .../SessionDel.swift:13:10: Objective-C method 'urlSession:downloadTask:didFinishDownloadingTo:' provided by method 'urlSession(_:downloadTask:didFinishDownloadingTo:)' does not match the requirement's selector ('URLSession:downloadTask:didFinishDownloadingToURL:’)

The signature that Xcode’s autocompletion suggests is this:

> func urlSession(session: NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingTo location: NSURL)


…which is slightly different from the one in the error message (the first parameter), but neither works. I’ve also tried several variants with regard to capitalization and truncation of parameter names, but cannot get this to compile. Is this a known/temporary issue in the current snapshot, or should I file a bug report?

Cheers
Sebastian



More information about the swift-users mailing list