URLSessionCancellationSwift 1.0.1

URLSessionCancellationSwift 1.0.1

测试已测试
Lang语言 SwiftSwift
许可证 MIT
Released最后发布2017年1月
SwiftSwift 版本3.0
SPM支持 SPM

Shagun MadhikarmiDaniela Dias 维护。



  • Shagun Madhikarmi

URLSession+Cancellation

对 iOS/macOS Foundation 库的 NSURLSession 类的扩展,以便支持取消特定 URL 的下载。

依赖项

安装

手动

  • URLSession+Cancellation.swift 文件添加到你的 Xcode 项目中。

使用方法

请看 ViewController.swift 中的示例使用。

已经为 NSURLSession 类添加了一些方法

cancelAllRequests

使用 cancelAllRequests 函数来取消会话中所有挂起的请求。

session.cancelAllRequests()

cancelRequestForURL

使用 cancelRequestForURL 函数来取消特定 URL 的请求

let url = URL(string: "http://puppygifs.tumblr.com/api/read/json")
session.cancelRequestForURL(url)

注意,NSURLSession 完成处理程序将使用错误代码 NSURLErrorCancelled 和域 NSURLErrorDomain 被调用。

贡献

请注意,本项目以贡献者行为准则发布。参与本项目即表示您同意遵守其条款。请参阅 行为准则 文件。

维护者

联系

[email protected]

许可证

URLSession+Cancellation 在 MIT 许可下发布。请参阅 许可证