swift - 使用 Swift 委托(delegate)

标签 swift delegates

我正在用 swift 为 NSOperation 编写一个子类。但是,我遇到了一个奇怪的问题。

 class Downloader : NSOperation, NSURLSessionDelegate,    NSURLSessionDownloadDelegate{}

当我添加“NSURLSessionDownloadDelegate”时,它会显示错误:“类型‘Downloader’不符合协议(protocol)‘NSURLSessionDownloadDelegate’” 当我删除它时,一切都很好。 你知道为什么吗? 谢谢,提前!

最佳答案

根据苹果文档 https://developer.apple.com/library/prerelease/ios/documentation/Foundation/Reference/NSURLSessionDownloadDelegate_protocol/index.html

实现 URLSession:downloadTask:didFinishDownloadingToURL: 是必须的,

请确保您已实现它。

关于swift - 使用 Swift 委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34849050/

相关文章:

objective-c - 在自定义 View 中重现 tableView 委托(delegate)行为

iOS - 如何获得委托(delegate)类

swift - 两个 Firebase 用户之间的 Xcode 快速日历事件请求

ios - 如何从字符串中提取表情符号?

java - 玩! Framework 2.5 如何在异步回调中返回 delegate.call(ctx)

jquery 委托(delegate)语法 .each()

c# - 在不弄乱代码的情况下编写委托(delegate)

swift - 书籍示例在 SWIFT Playground 中不起作用

ios - swift 3 : replace c style for-loop with float increment

ios - URLsession 委托(delegate)函数出错