Latest 1.0.1
Homepage https://github.com/ustwo/urlsession-cancellation-swift
License MIT
Platforms ios 8.3, requires ARC
Authors

License

URLSession+Cancellation

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

Dependencies

Installation

CocoaPods

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 Podfile:

platform :ios, '8.3'

use_frameworks!

pod 'URLSessionCancellationSwift', '~> 1.0.1'

Then, run the following command:

$ pod install

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.

Latest podspec

{
    "name": "URLSessionCancellationSwift",
    "version": "1.0.1",
    "license": "MIT",
    "summary": "An extension to iOS / macOS Foundation library's NSURLSession class to add support for cancelling specific URLs from being downloaded.",
    "homepage": "https://github.com/ustwo/urlsession-cancellation-swift",
    "authors": {
        "Shagun Madhikarmi": "[email protected]"
    },
    "source": {
        "git": "https://github.com/ustwo/urlsession-cancellation-swift.git",
        "tag": "v1.0.1"
    },
    "platforms": {
        "ios": "8.3"
    },
    "source_files": "Sources/*.swift",
    "requires_arc": true,
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This