An extension to iOS / macOS Foundation library's
NSURLSession class to add support for cancelling specific URLs from being downloaded.
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate URLSessionCancellationSwift into your Xcode project using CocoaPods, specify it in your
platform :ios, '8.3' use_frameworks! pod 'URLSessionCancellationSwift', '~> 1.0.1'
Then, run the following command:
$ pod install
- Add the
URLSession+Cancellation.swiftfile to your Xcode project.
ViewController.swift for sample usage.
There are a couple of methods added to
cancelAllRequests function to cancel all pending requests for the session.
cancelRequestForURL function to cancel a request for a specific URL
let url = URL(string: "http://puppygifs.tumblr.com/api/read/json") session.cancelRequestForURL(url)
NSURLSession completion handler will be called with an error code
NSURLErrorCancelled and domain
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.
URLSession+Cancellation is released under the MIT License. See License.