what is the delegate of these NSURLSession methods

2019-09-22 07:15发布

问题:

XCode is not auto completing this methods i did set the delegate for

NSURLSessionTaskDelegate,NSURLSessionDelegate,NSURLSessionDownloadDelegate

but it still not completing so i feel that i am setting the wrong delegates cause thats what xcode do when i set the wrong delegate

URLSession(_:downloadTask:didResumeAtOffset:expectedTotalBytes:)
URLSession(_:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:)
URLSession(_:downloadTask:didFinishDownloadingToURL:)

well whats wrong with swift this time

回答1:

If you type this into Playground:

class Downloader : NSObject, NSURLSessionTaskDelegate, NSURLSessionDownloadDelegate {

}

and then start typing inside the class URLS you get all the autocompletion stuff. Try that and if this does not work restart Xcode. Maybe "cleaning" the project will also help.

Please also note that the methods you reference in your question are defined by the NSURLSessionDownloadDelegate, which you did not include.

Sometimes you have to use the up or down arrow key to scroll to the right autocompletion entry.