Instance Method

addTarget:action:

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

Declaration

- (void)addTarget:(id)target action:(SEL)action;

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:

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

Discussion

Call the 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.

See Also

Handling Events

- addTargetWithHandler:

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

- removeTarget:

Removes a target from the remote command object.

- removeTarget:action:

Removes a target and action from a remote command object.

MPRemoteCommandHandlerStatus

Constant indicating the status of a command.