Swift 中这些 NSURLSession 方法的委托是什么? [英] what is the delegate of these NSURLSession methods in Swift?
问题描述
XCode 不是自动完成此方法我确实为
XCode is not auto completing this methods i did set the delegate for
NSURLSessionTaskDelegate
,NSURLSessionDelegate,NSURLSessionDownloadDelegate
但它仍然没有完成,所以我觉得我设置了错误的委托,因为当我设置了错误的委托时,xcode 会这样做
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:)
这次 swift 怎么了
well whats wrong with swift this time
推荐答案
如果你在 Playground 中输入:
If you type this into Playground:
class Downloader : NSObject, NSURLSessionTaskDelegate, NSURLSessionDownloadDelegate {
}
然后开始在 URLS
类中输入,你会得到所有自动完成的东西.尝试一下,如果这不起作用,请重新启动 Xcode.也许清理"项目也会有所帮助.
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.
另请注意,您在问题中引用的方法是由 NSURLSessionDownloadDelegate
定义的,而您并未包含该方法.
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.
这篇关于Swift 中这些 NSURLSession 方法的委托是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!