CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

URLSessionCancellationSwift 1.0.1

URLSessionCancellationSwift 1.0.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jan 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Shagun Madhikarmi, Daniela Dias.



  • By
  • Shagun Madhikarmi

URLSession+Cancellation

An extension to iOS / macOS Foundation library’s NSURLSession class to add support for cancelling specific URLs from being downloaded.

Dependencies

Installation

Manually

  • Add the URLSession+Cancellation.swift file to your Xcode project.

Usage

See ViewController.swift for sample usage.

There are a couple of methods added to NSURLSession class:

cancelAllRequests

Use the cancelAllRequests function to cancel all pending requests for the session.

session.cancelAllRequests()

cancelRequestForURL

Use the cancelRequestForURL function to cancel a request for a specific URL

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

Note. the NSURLSession completion handler will be called with an error code NSURLErrorCancelled and domain NSURLErrorDomain.

Contributing

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See the Code of Conduct file.

Maintainers

Contact

[email protected]

License

URLSession+Cancellation is released under the MIT License. See License.