Instance Method

sendAction:to:from:

Sends the given action message to the given target.

Declaration

- (BOOL)sendAction:(SEL)action to:(id)target from:(id)sender;

Parameters

anAction

The action message you want to send.

aTarget

The target object that defines the specified action message.

sender

The object to pass for the action message’s parameter.

Return Value

YES if the action was successfully sent; otherwise NO. This method also returns NO if anAction is nil.

Discussion

If aTarget is nil, sharedApplication looks for an object that can respond to the message—that is, an object that implements a method matching anAction. It begins with the first responder of the key window. If the first responder can’t respond, it tries the first responder’s next responder and continues following next responder links up the responder chain. If none of the objects in the key window’s responder chain can handle the message, sharedApplication attempts to send the message to the key window’s delegate.

If the delegate doesn’t respond and the main window is different from the key window, sharedApplication begins again with the first responder in the main window. If objects in the main window can’t respond, sharedApplication attempts to send the message to the main window’s delegate. If still no object has responded, sharedApplication tries to handle the message itself. If sharedApplication can’t respond, it attempts to send the message to its own delegate.

See Also

Posting Actions

- tryToPerform:with:

Dispatches an action message to the specified target.

- targetForAction:

Returns the object that receives the action message specified by the given selector

- targetForAction:to:from:

Searches for an object that can receive the message specified by the given selector.