|Header file directories|
The iTunes Library framework provides facilities for retrieving the properties of media items in a user’s iTunes library. This framework was designed to replace the iTunes XML file that developers query to fetch track and playlist metadata. iTunes library access is read-only.
To use this framework, create an
ITLibrary object by calling the
libraryWithAPIVersion class method, as shown in Listing I-1. You can interrogate the instance returned to obtain its properties and the properties of its media items. For example:
Listing I-1 Creating and initializing an ITLibrary
NSError *error = nil;
ITLibrary *library = [ITLibrary libraryWithAPIVersion:@"1.0" error:&error];
NSArray *playlists = library.allPlaylists; // <- NSArray of ITLibPlaylist
NSArray *tracks = library.allMediaItems; // <- NSArray of ITLibMediaItem
To use the iTunes Library framework in your project, you must add the iTunes Library framework (located at
/Library/Frameworks/iTunesLibrary.framework) to the project. You will also need to edit the build setting “FRAMEWORK_SEARCH_PATHS” to include
/Library/Frameworks/iTunesLibrary.framework. The iTunes Library framework is available to users running iTunes v11.0 or above.