---
title: "getPlaylist(with:creationMetadata:completionHandler:)"
framework: mediaplayer
role: symbol
role_heading: Instance Method
path: "mediaplayer/mpmedialibrary/getplaylist(with:creationmetadata:completionhandler:)"
---

# getPlaylist(with:creationMetadata:completionHandler:)

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

## Declaration

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

```swift
func getPlaylist(with uuid: UUID, creationMetadata: MPMediaPlaylistCreationMetadata?) async throws -> MPMediaPlaylist
```

## 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.

## Discussion

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.
