Mac Developer Library

Developer

StoreKit Framework Reference SKDownload Class Reference

Options
Deployment Target:

On This Page
Language:

SKDownload

A SKDownload object represents downloadable content associated with a product. When you create a product in iTunes Connect, you can associate one or more pieces of downloadable content with it. Then, at runtime, when a product is purchased by a user, your app uses SKDownload objects to download the content from the App Store. More...

Inheritance


Conforms To


Import Statement


import StoreKit @import StoreKit;

Availability


Available in OS X v10.8 and later.
  • A string that uniquely identifies the downloadable content. (read-only)

    Declaration

    Swift

    var contentIdentifier: String! { get }

    Objective-C

    @property(readonly) NSString *contentIdentifier

    Discussion

    Each piece of downloadable content associated with a product has its own unique identifier. The content identifier is specified in iTunes Connect when you add the content.

    Import Statement

    import StoreKit

    Availability

    Available in OS X v10.8 and later.

  • The length of the downloadable content, in bytes. (read-only)

    Declaration

    Swift

    @NSCopying var contentLength: NSNumber! { get }

    Objective-C

    @property(copy, readonly) NSNumber *contentLength

    Import Statement

    import StoreKit

    Availability

    Available in OS X v10.8 and later.

  • A string that identifies which version of the content is available for download. (read-only)

    Declaration

    Swift

    var contentVersion: String! { get }

    Objective-C

    @property(copy, readonly) NSString *contentVersion

    Discussion

    The version string must be formatted as a series of integers separated by periods.

    Import Statement

    import StoreKit

    Availability

    Available in OS X v10.8 and later.

  • state state Property

    The current state of the download object. (read-only)

    Declaration

    Swift

    var state: SKDownloadState { get }

    Objective-C

    @property(readonly) SKDownloadState state

    Discussion

    After you queue a download object, the payment queue object calls your transaction observer when the state of the download object changes. Your transaction observer should read the state property and use it to determine how to proceed. For more information on the different states, see Download States.

    Import Statement

    import StoreKit

    Availability

    Available in OS X v10.8 and later.

  • progress progress Property

    A value that indicates how much of the file has been downloaded. (read-only)

    Declaration

    Swift

    var progress: Float { get }

    Objective-C

    @property(readonly) float progress

    Discussion

    The value of this property is a floating point number between 0.0 and 1.0, inclusive, where 0.0 means no data has been download and 1.0 means all the data has been downloaded. Typically, your app uses the value of this property to update a user interface element, such as a progress bar, that displays how much of the file has been downloaded.

    Do not use the value of this property to determine whether the download has completed. Instead, use the downloadState property.

    Import Statement

    import StoreKit

    Availability

    Available in OS X v10.8 and later.

  • An estimated time, in seconds, to finish downloading the content. (read-only)

    Declaration

    Swift

    var timeRemaining: NSTimeInterval { get }

    Objective-C

    @property(readonly) NSTimeInterval timeRemaining

    Discussion

    The system attempts to estimate how long it will take to finish downloading the file. If it cannot create a good estimate, the value of this property is set to SKDownloadTimeRemainingUnknown.

    Import Statement

    import StoreKit

    Availability

    Available in OS X v10.8 and later.

  • error error Property

    The error that prevented the content from being downloaded. (read-only)

    Declaration

    Swift

    @NSCopying var error: NSError! { get }

    Objective-C

    @property(copy, readonly) NSError *error

    Discussion

    The value of this property is valid only when the downloadState property is set to SKDownloadStateFailed.

    Import Statement

    import StoreKit

    Availability

    Available in OS X v10.8 and later.

  • The local location of the downloaded file. (read-only)

    Declaration

    Swift

    @NSCopying var contentURL: NSURL! { get }

    Objective-C

    @property(copy, readonly) NSURL *contentURL

    Discussion

    The value of this property is valid only when the downloadState property is set to SKDownloadStateFinished. The URL becomes invalid after the transaction object associated with the download is finalized.

    Import Statement

    import StoreKit

    Availability

    Available in OS X v10.8 and later.

  • Returns the local location for the previously downloaded flie.

    Declaration

    Swift

    class func contentURLForProductID(_ productID: String!) -> NSURL!

    Objective-C

    + (NSURL *)contentURLForProductID:(NSString *)productID

    Parameters

    productID

    The product identifier.

    Return Value

    The local location for the previously downloaded flie.

    Discussion

    Use this method to locate the content on subsequent launches of your app.

    Import Statement

    import StoreKit

    Availability

    Available in OS X v10.8 and later.

  • Deletes the previously downloaded file.

    Declaration

    Swift

    class func deleteContentForProductID(_ productID: String!)

    Objective-C

    + (void)deleteContentForProductID:(NSString *)productID

    Parameters

    productID

    The product identifier.

    Import Statement

    import StoreKit

    Availability

    Available in OS X v10.8 and later.

  • The states that a download operation can be in.

    Declaration

    Swift

    struct SKDownloadState { init(_ value: Int) var value: Int }

    Objective-C

    enum { SKDownloadStateWaiting, SKDownloadStateActive, SKDownloadStatePaused, SKDownloadStateFinished, SKDownloadStateFailed, SKDownloadStateCancelled, }; typedef NSInteger SKDownloadState;

    Constants

    • SKDownloadStateWaiting

      SKDownloadStateWaiting

      Indicates that the download has not started yet.

      Available in OS X v10.8 and later.

    • SKDownloadStateActive

      SKDownloadStateActive

      Indicates that the content is currently being downloaded.

      Available in OS X v10.8 and later.

    • SKDownloadStatePaused

      SKDownloadStatePaused

      Indicates that your app paused the download.

      Available in OS X v10.8 and later.

    • SKDownloadStateFinished

      SKDownloadStateFinished

      Indicates that the content was successfully downloaded.

      Available in OS X v10.8 and later.

    • SKDownloadStateFailed

      SKDownloadStateFailed

      Indicates that an error occurred while the file was being downloaded.

      Available in OS X v10.8 and later.

    • SKDownloadStateCancelled

      SKDownloadStateCancelled

      Indicates that your app canceled the download.

      Available in OS X v10.8 and later.

    Import Statement

    import StoreKit

    Availability

    Available in OS X v10.8 and later.