NKAssetDownload Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/NewsstandKit.framework
Availability
Available in iOS 5.0 and later.
Declared in
NKAssetDownload.h

Overview

An instance of the NKAssetDownload class represents an asset that is being downloaded (or has downloaded) for an issue of a Newsstand application.

An asset can be either a component of an issue—for example, an HTML file, a plain-text file, an image, or a video—or the entire issue compressed in a ZIP or other archive. The latter approach is recommended.

You create an NKAssetDownload instance using the NKIssue method addAssetWithRequest:; you pass into this method an NSURLRequest object that contains the URL locating the asset on the application’s server. To begin downloading the asset, call downloadWithDelegate: on the NKAssetDownload object. The delegate specified as the parameter of this message must adopt the NSURLConnectionDownloadDelegate protocol. It should implement the three methods specific to handling downloads of issue assets:

If a Newsstand application terminates while asset downloading is underway, the downloading continues in the background. When the asset is downloaded, the application is brought to the foreground if it has a newsstand-content value for the “UIBackgroundModes” in Information Property List Key Reference array in the information property list. It should obtain an instance of NKIssue and iterate through the NKAssetDownload objects in the downloadingAssets array; for each object, call downloadWithDelegate: on it and have the delegate process the remaining downloads.

Tasks

Downloading an Issue Asset

Getting the Asset Identifier

Accessing Asset Information

Properties

identifier

An identifier for the downloaded asset.

@property (nonatomic, readonly) NSString *identifier
Discussion

A unique string identifier that Newsstand Kit generates and assigns to the asset download.

Availability
  • Available in iOS 5.0 and later.
Declared In
NKAssetDownload.h

issue

The issue associated with the asset download. (read-only)

@property(nonatomic, readonly) NKIssue *issue
Availability
  • Available in iOS 5.0 and later.
Declared In
NKAssetDownload.h

URLRequest

The URL request associated with the asset download. (read-only)

@property(nonatomic, readonly) NSURLRequest *URLRequest
Discussion

This object was passed into the the addAssetWithRequest: method of NKIssue to create the NKAssetDownload object.

Availability
  • Available in iOS 5.0 and later.
Declared In
NKAssetDownload.h

userInfo

Application-specific information that is saved with the asset-download object.

@property (nonatomic, copy) NSDictionary *userInfo
Discussion

This dictionary is for storing arbitrary key-value pairs associated with the asset download. The keys and values must be valid property-list types; if any are not, an exception is raised. Examples of download-related information you might store in the dictionary are the file (issue) name, the download URL, the encoding mechanisms, and custom identifiers. However, for performance reasons the dictionary content should be as minimal as possible. You can also assign nil to this property.

Availability
  • Available in iOS 5.0 and later.
Declared In
NKAssetDownload.h

Instance Methods

downloadWithDelegate:

Returns a connection object and starts downloading the issue asset with a specified delegate to handle callbacks.

- (NSURLConnection *)downloadWithDelegate:(id < NSURLConnectionDownloadDelegate >)delegate
Parameters
delegate

A object that adopts the NSURLConnectionDownloadDelegate protocol and implements the methods related to issue-asset downloads.

Return Value

An object representing the URL connection.

Discussion

Upon receipt of this message, the Newsstand Kit framework creates a NSURLConnection object from the NSURLRequest object encapsulated by the receiver, returns the connection object, and typically begins downloading the issue asset. (If the download is already underway, it simply returns the associated connection object.) It sends messages to the connection-download delegate at the appropriate junctures until the download concludes.

Availability
  • Available in iOS 5.0 and later.
Declared In
NKAssetDownload.h