ZDCDownloadTicket

@interface ZDCDownloadTicket : NSObject

The DownloadManager automatically consolidates multiple requests for the same item into a single task. This minimizes bandwidth and improves app response time.

However, it also means that your particular request may not be the only requester for a resource. For example, there may be other ViewControllers within your app that are also waiting for the same data. As such, it’s not safe to cancel downloads directly. Rather you’re encouraged to cancel requests through the ticket instance. This allows the ticket to handle complex cases where there are multiple requests for the resource. And it also handles cancelling the downloads such that they can be resumed later.

  • The progress item can be used to track the download.

    This progress item is also registered with the ZDCProgressManager, and can be fetched from there as well. This also means you get throughput information (NSProgressThroughputKey) and estimated time remaining (NSProgressEstimatedTimeRemainingKey) for this progress item.

    @important Do NOT cancel the download directly through the progress instance. Use -[ZDCDownloadTicket cancel] or -[ZDCDownloadTicket ignore] instead.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSProgress *_Nonnull progress;

    Swift

    var progress: Progress { get }
  • Indicates to the DownloadManager that you no longer need the data, and that its free to cancel the download (as long as all other tickets agree).

    If the download is in progress, it will be cancelled in a resumable manner. Future requests for the same resource will resume where this download left off.

    Your completionBlock will be removed from the array of listeners.

    Declaration

    Objective-C

    - (void)cancel;

    Swift

    func cancel()
  • Indicates to the DownloadManager that you no longer need the data, but that you wish the download to continue as planned.

    This is commonly used when the request included either -[ZDCDownloadOptions cacheToDiskManager] or -[ZDCDownloadOptions savePersistentlyToDiskManager]. In other words, you anticipate needing the object again in the near future, and you want the download to complete so that it’s cached on disk, and ready for next time.

    Your completionBlock will be removed from the array of listeners.

    Declaration

    Objective-C

    - (void)ignore;

    Swift

    func ignore()