<!--
{
  "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(_:action:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Media Player"
    ],
    "preciseIdentifier" : "c:objc(cs)MPRemoteCommand(im)addTarget:action:"
  },
  "title" : "addTarget(_:action:)"
}
-->

# addTarget(_:action:)

Adds a target object to be called when an event is received.

```
func addTarget(_ target: Any, action: Selector)
```

## Parameters

`target`

The object to receive action messages sent by the receiver when the represented remote command is triggered. The value must not be `nil`.

`action`

A selector identifying the method on the target to be called. The value must not be `NULL`.

    The method to be called must have the following signature:

```objc
- (MPRemoteCommandHandlerStatus) handleCommand: (MPRemoteCommandEvent*) event;
```

## Discussion

Call the [`addTarget(_:action:)`](/documentation/MediaPlayer/MPRemoteCommand/addTarget(_:action:)) method multiple times to specify multiple target-action pairs. If a specific target-action pair has already been added, the request is ignored. You can add multiple actions for a single target by calling this method multiple times using the same target, but different actions.

The command object does not keep a strong reference to the target; you should remove the target before the target is deallocated.

---

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)