ZDCDownloadOptions

@interface ZDCDownloadOptions : NSObject <NSCoding, NSCopying>

A simple container for holding several different download options.

  • If set to YES, then after downloading the file, the DownloadManager will store the file to disk via the DiskManager.

    The file will be stored in a non-persistent mode. That is, the file will be part of a storage pool cache managed by the DiskManager. And the DiskManager will automatically delete files from this pool when its (configurable) max size is exceeded. Also, the OS is allowed to delete the file due to low-disk-space pressure.

    The default value is NO.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL cacheToDiskManager;

    Swift

    var cacheToDiskManager: Bool { get set }
  • If set to YES, then after downloading the file, the DownloadManager will store the file to disk via the DiskManager.

    The file will be stored in a persistent mode. That is, the file won’t be deleted unless you ask the DiskManager to delete it. If you simply want to cache the value to disk temporarily, while allowing the DiskManager or the OS to delete it as needed, then use the cacheToDiskManager property instead.

    @important You are storing the file to disk in a persistent manner, and your app is responsible for deleting the file via the DiskManager.

    The default value is NO.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL savePersistentlyToDiskManager;

    Swift

    var savePersistentlyToDiskManager: Bool { get set }
  • Set to YES if you want to allow the download to continue while the app is backgrounded.

    This value only applies to iOS-based platforms. The default value is NO.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL canDownloadWhileInBackground;

    Swift

    var canDownloadWhileInBackground: Bool { get set }
  • Applies to user avatar downloads.

    Users are allowed to link multiple social identities to their user account. For example, they may link Facebook, LinkedIn, Google, etc. This specifies the particular social identifier associated with the download.

    (This value comes from ZDCUser.identities[x].identityID)

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *identityID;

    Swift

    var identityID: String? { get set }
  • The completionConsolidationTag helps you prevent multiple callbacks.

    It’s common to have a function that requests a download (if needed). However, this function may run multiple times. For example, it may run as part of the dataSource for tableView/collectionView, and thereform may request a download dozens of times as the user scrolls around the view.

    The optimium result would be:

    1. perform the download only once (consolidate network requests)
    2. perform the completion callback only once (consolidate completion callbacks)

    The DownloadManager automatically consolidates network requests. However, the DownloadManager will invoke every queued completionBlock when the download completes. This may not be what you want. Sometimes you only want to receive a single callback, regardless of how many times your code requested the download. (i.e. consolidate completion callbacks) When this is the case, you can set a non-nil completionConsolidationTag. And if there’s already a queued completionBlock with the same completionConsolidationTag, then the passed completionBlock won’t be added to the queue again.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable)
        NSString *completionConsolidationTag;

    Swift

    var completionConsolidationTag: String? { get set }