<!--
{
  "availability" : [
    "iOS: 10.3.0 -",
    "iPadOS: 10.3.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MediaPlayer",
  "identifier" : "/documentation/MediaPlayer/MPMusicPlayerApplicationController/perform(queueTransaction:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Media Player"
    ],
    "preciseIdentifier" : "c:objc(cs)MPMusicPlayerApplicationController(im)performQueueTransaction:completionHandler:"
  },
  "title" : "perform(queueTransaction:completionHandler:)"
}
-->

# perform(queueTransaction:completionHandler:)

Changes the contents of the media items in the queue.

```
func perform(queueTransaction: @escaping (MPMusicPlayerControllerMutableQueue) -> Void, completionHandler: @escaping @Sendable (MPMusicPlayerControllerQueue, (any Error)?) -> Void)
```

## Parameters

`queueTransaction`

A block that the system calls while it creates the queue.

- queue: The queue to modify.

`completionHandler`

A block that the system calls after the user accepts the new queue.

- queue: The newly modified queue that the user accepted.
- 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

Perform all of your queue modifications inside of the queue transition block. After the system modifies the queue inside of the queue transition block, it returns the new queue from the completion handler after the user accepts the new queue. Don’t access the completion handler’s queue outside of the completion handler.

If you modify the queue outside of the completion handler, register for the [`MPMusicPlayerControllerQueueDidChangeNotification`](/documentation/MediaPlayer/MPMusicPlayerControllerQueueDidChangeNotification) notification and ensure your app responds accordingly.

---

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)