NKLibrary Class Reference

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

Overview

An instance of the NKLibrary class represents the library of issues for a newsstand content application.

You create and add issues to the library by calling the addIssueWithName:date: method. and remove them from the library by calling the removeIssue: method. You can access all issues through the issues property or request a specific issue by calling the issueWithName: method. For more information about the objects representing issues, see NKIssue Class Reference.

The downloadingAssets array holds any downloading assets for any issues. (A downloading asset is represented by a NKAssetDownload object.) A newsstand content application should, when it launches, iterate through this array and call downloadWithDelegate: on each item to have the downloaded assets completely processed.

An application can maintain as many back issues of the library as it wants, in addition to the most current issue. The Newsstand Kit framework uses the dates of issues and whatever issue is assigned to the currentlyReadingIssue property as hints in low disk space scenarios.

Tasks

Getting the Shared Library Instance

Managing Library Issues

Accessing Downloading Assets

Properties

currentlyReadingIssue

Accesses or sets the newsstand issue that the user is currently reading.

@property(nonatomic, retain) NKIssue *currentlyReadingIssue
Discussion

When you ascertain what issue the user is currently reading, you should set this property to the corresponding NKIssue instance. Newsstand Kit takes this setting into consideration when it purges back issues because of low levels of available flash storage.

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

downloadingAssets

The assets that are currently being downloaded for one or more issues of the newsstand content library. (read-only)

@property(nonatomic, readonly) NSArray *downloadingAssets
Discussion

When a newsstand application launches, it should enumerate the NKAssetDownload objects in the returned array, call downloadWithDelegate: on each object, and process each downloaded asset.

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

issues

Returns the current issues of the newsstand content library. (read-only)

@property(nonatomic, readonly) NSArray *issues
Discussion

Each item in the returned array is an instance of NKIssue. If there are no issues, an empty array is returned.

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

Class Methods

sharedLibrary

Returns the shared instance representing the newsstand content library.

+ (NKLibrary *)sharedLibrary
Return Value

A singleton instance of the NKLibrary class or nil if the instance couldn’t be created.

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

Instance Methods

addIssueWithName:date:

Creates a newsstand issue and adds it to the content library.

- (NKIssue *)addIssueWithName:(NSString *)name date:(NSDate *)date
Parameters
name

The name of the newsstand issue. This parameter is required and the name must be unique across all issues in the library.

date

The date the newsstand issue was released. This parameter is required.

Return Value

An instance of the NKIssue class or nil if the instance couldn’t be created.

Discussion

The created issue is automatically added to the newsstand content library. Issues are ordered by their release date. The release date of an issue can be a factor when Newsstand Kit must delete back issues because of low levels of available flash storage.

This method throws an exception if the name and date parameters are nil or are otherwise not valid objects. It also throws an exception if you pass in an issue name that is used by another issue.

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

issueWithName:

Returns an issue of the newsstand content library specified by name.

- (NKIssue *)issueWithName:(NSString *)name
Parameters
name

The name of an issue.

Return Value

An instance of NKIssue representing the issue or nil if the issue couldn’t be retrieved—for example, if an issue of that name doesn’t exist in the library.

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

removeIssue:

Removes the specified issue from the newsstand content library.

- (void)removeIssue:(NKIssue *)issue
Parameters
issue

An instance of NKIssue representing an issue in the newsstand content library.

Discussion

When an issue is removed, any data at the file-system location identified by the issue’s content URL (accessed through the contentURL property of NKIssue) is deleted from disk. If you have issue content elsewhere in the application sandbox, it’s your responsibility to clean it up. Calling this method also cancels any asset downloads for that issue that are underway.

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