iOS 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 iOS 6.0 and later.
  • A string that uniquely identifies the downloadable content. (read-only)

    Declaration

    Swift

    var contentIdentifier: String! { get }

    Objective-C

    @property(nonatomic, 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 iOS 6.0 and later.

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

    Declaration

    Swift

    var contentLength: Int64 { get }

    Objective-C

    @property(nonatomic, readonly) long long contentLength

    Import Statement

    import StoreKit

    Availability

    Available in iOS 6.0 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(nonatomic, 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 iOS 6.0 and later.

  • The transaction associated with the downloadable file. (read-only)

    Declaration

    Swift

    var transaction: SKPaymentTransaction! { get }

    Objective-C

    @property(nonatomic, readonly) SKPaymentTransaction *transaction

    Discussion

    A download object is always associated with a payment transaction. The download object may only be queued after payment is processed and before the transaction is finished.

    Import Statement

    import StoreKit

    Availability

    Available in iOS 6.0 and later.

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

    Declaration

    Swift

    var downloadState: SKDownloadState { get }

    Objective-C

    @property(nonatomic, readonly) SKDownloadState downloadState

    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 downloadState 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 iOS 6.0 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(nonatomic, 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 iOS 6.0 and later.

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

    Declaration

    Swift

    var timeRemaining: NSTimeInterval { get }

    Objective-C

    @property(nonatomic, 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 iOS 6.0 and later.

  • error error Property

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

    Declaration

    Swift

    var error: NSError! { get }

    Objective-C

    @property(nonatomic, 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 iOS 6.0 and later.

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

    Declaration

    Swift

    var contentURL: NSURL! { get }

    Objective-C

    @property(nonatomic, 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 iOS 6.0 and later.

  • The states that a download operation can be in.

    Declaration

    Swift

    enum SKDownloadState : Int { case Waiting case Active case Paused case Finished case Failed case Cancelled }

    Objective-C

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

    Constants

    • Waiting

      SKDownloadStateWaiting

      Indicates that the download has not started yet.

      Available in iOS 6.0 and later.

    • Active

      SKDownloadStateActive

      Indicates that the content is currently being downloaded.

      Available in iOS 6.0 and later.

    • Paused

      SKDownloadStatePaused

      Indicates that your app paused the download.

      Available in iOS 6.0 and later.

    • Finished

      SKDownloadStateFinished

      Indicates that the content was successfully downloaded.

      Available in iOS 6.0 and later.

    • Failed

      SKDownloadStateFailed

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

      Available in iOS 6.0 and later.

    • Cancelled

      SKDownloadStateCancelled

      Indicates that your app canceled the download.

      Available in iOS 6.0 and later.

    Import Statement

    import StoreKit

    Availability

    Available in iOS 6.0 and later.

  • Time values used to show special download states.

    Declaration

    Swift

    var SKDownloadTimeRemainingUnknown: NSTimeInterval

    Objective-C

    NSTimeInterval SKDownloadTimeRemainingUnknown;

    Constants

    • SKDownloadTimeRemainingUnknown

      SKDownloadTimeRemainingUnknown

      Indicates that the system cannot determine how much time is needed to finish downloading the content.

      Available in iOS 6.0 and later.

    Import Statement