<!--
{
  "availability" : [
    "macCatalyst: 14.0.0 -",
    "macOS: 10.13.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "iTunesLibrary",
  "identifier" : "/documentation/iTunesLibrary/ITLibrary/init(apiVersion:)-71e74",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "iTunes Library"
    ],
    "preciseIdentifier" : "c:objc(cs)ITLibrary(im)initWithAPIVersion:error:"
  },
  "title" : "init(apiVersion:)"
}
-->

# init(apiVersion:)

Initializes an instance of [`ITLibrary`](/documentation/iTunesLibrary/ITLibrary) that can retrieve media entities.

```
convenience init(apiVersion requestedAPIVersion: String) throws
```

## Parameters

`requestedAPIVersion`

The version of the iTunesLibrary API that the app is requesting. Provide `"1.0"` if unknown.

## Return Value

An [`ITLibrary`](/documentation/iTunesLibrary/ITLibrary) instance that can retrieve media entities, or `nil` if the method fails.

## Discussion

During initialization of the [`ITLibrary`](/documentation/iTunesLibrary/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.

```objc
#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
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)