what is the delegate of these NSURLSession methods in Swift?

房东的猫 提交于 2019-12-13 22:56:03

问题


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.



来源:https://stackoverflow.com/questions/25574391/what-is-the-delegate-of-these-nsurlsession-methods-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!