<!--
{
  "availability" : [
    "iOS: 9.3.0 -",
    "iPadOS: 9.3.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MediaPlayer",
  "identifier" : "/documentation/MediaPlayer/MPMediaLibrary/getPlaylist(with:creationMetadata:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Media Player"
    ],
    "preciseIdentifier" : "c:objc(cs)MPMediaLibrary(im)getPlaylistWithUUID:creationMetadata:completionHandler:"
  },
  "title" : "getPlaylist(with:creationMetadata:completionHandler:)"
}
-->

# getPlaylist(with:creationMetadata:completionHandler:)

Retrieves an app maintained existing playlist or creates a new playlist when no playlist exists.

```
func getPlaylist(with uuid: UUID, creationMetadata: MPMediaPlaylistCreationMetadata?, completionHandler: @escaping @Sendable (MPMediaPlaylist?, (any Error)?) -> Void)
```

## Parameters

`uuid`

The unique identifier for the playlist.

`creationMetadata`

The metadata that the system uses to create a new playlist, which it ignores if a playlist already exists.

`completionHandler`

A block that the system calls after it retrieves or creates the playlist.

- playlist: Contains the playlist identified by the UUID or the newly created playlist.
- error: If an error occurred, this parameter holds the error object that explains the error. Otherwise, the value of this parameter is <doc://com.apple.documentation/documentation/ObjectiveC/nil-227m0>.

## Discussion

This function retrieves the playlist associated with the UUID. Create a static instance of the UUID using a previously generated UUID. Creating a new UUID using `init(uuidString:)` to retrieve a playlist doesn’t guarantee its retrieval.

When there’s no playlist associated with the UUID, the system creates a new playlist with the UUID and the creation metadata. The system ignores this metadata when the playlist already exists.

---

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)