<!--
{
  "availability" : [
    "iOS: 7.1.0 -",
    "iPadOS: 7.1.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.2 -",
    "tvOS: 7.1.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 5.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MediaPlayer",
  "identifier" : "/documentation/MediaPlayer/MPRemoteCommand/addTarget(handler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Media Player"
    ],
    "preciseIdentifier" : "c:objc(cs)MPRemoteCommand(im)addTargetWithHandler:"
  },
  "title" : "addTarget(handler:)"
}
-->

# addTarget(handler:)

Adds a block to be called when an event is received.

```
func addTarget(handler: @escaping (MPRemoteCommandEvent) -> MPRemoteCommandHandlerStatus) -> Any
```

## Parameters

`handler`

A block object to handle the [`MPRemoteCommandEvent`](/documentation/MediaPlayer/MPRemoteCommandEvent).

## Return Value

An opaque object associated with the designated handler.

## Discussion

Call the [`addTarget(handler:)`](/documentation/MediaPlayer/MPRemoteCommand/addTarget(handler:)) method to add a block to be called. Remove the handler by calling the [`removeTarget(_:)`](/documentation/MediaPlayer/MPRemoteCommand/removeTarget(_:)) method, passing in the object returned by this method.

---

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)