Instance Method

targetForAction:to:from:

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

Declaration

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

Parameters

anAction

The desired action message. May be nil, in which case this method will return nil.

aTarget

The target object to check. Specify nil if you want to search the responder chain starting with the current first responder.

sender

The potential sender for the action message.

Return Value

The object that can accept the specified action message or nil if no target object can receive the message from the specified sender. Returns nil if anAction is nil.

Discussion

The system looks for an object that implements a method matching anAction.

If aTarget is specified, the system verifies that it is a valid target for the provided action and sender, returning aTarget if valid, nil otherwise.

If the provided target is nil, the search begins with the first responder of the key window. The system follows the Responder object looking for targets. If no object capable of handling the message is found in the responder chain, returns nil.

See Also

Posting Actions

- tryToPerform:with:

Dispatches an action message to the specified target.

- sendAction:to:from:

Sends the given action message to the given target.

- targetForAction:

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