init(apiVersion:)
Initializes an instance of Itlibrary that can retrieve media entities.
Declaration
convenience init(apiVersion requestedAPIVersion: String) throwsParameters
- requestedAPIVersion:
The version of the iTunesLibrary API that the app is requesting. Provide
"1.0"if unknown.
Return Value
An ITLibrary instance that can retrieve media entities, or nil if the method fails.
Discussion
During initialization of the ITLibrary class, the system reads and parses the default iTunes database for the current user. All media entities cache in memory until deallocation of the object occurs.
Listing 1.
#import <iTunesLibrary/ITLibrary.h>
NSError * error = nil;
ITLibrary* library = [[ITLibrary alloc] initWithAPIVersion:@"1.0" error:&error];
if (library)
{
NSArray playlists = library.allPlaylists; // <- NSArray of ITLibPlaylist
NSArray mediaItems = library.allMediaItems; // <- NSArray of ITLibMediaItem
}