Instance Method

sendAction:to:from:forEvent:

Sends an action message identified by selector to a specified target.

Declaration

- (BOOL)sendAction:(SEL)action to:(id)target from:(id)sender forEvent:(UIEvent *)event;

Parameters

action

A selector identifying an action method. See the discussion for information on the permitted selector forms.

target

The object to receive the action message. If target is nil, the app sends the message to the first responder, from whence it progresses up the responder chain until it is handled.

sender

The object that is sending the action message. The default sender is the UIControl object that invokes this method.

event

A UIEvent object that encapsulates information about the event originating the action message.

Return Value

YES if a responder object handled the action message, NO if no object in the responder chain handled the message.

Discussion

Normally, this method is invoked by a UIControl object that the user has touched. The default implementation dispatches the action method to the given target object or, if no target is specified, to the first responder. Subclasses may override this method to perform special dispatching of action messages.

By default, this method pushes two parameters when calling the target. These last two parameters are optional for the receiver because it is up to the caller (usually a UIControl object) to remove any parameters it added. This design enables the action selector to be one of the following:

  • - (void)action

  • - (void)action:(id)sender

  • - (void)action:(id)sender forEvent:(UIEvent *)event

See Also

Controlling and Handling Events

- sendEvent:

Dispatches an event to the appropriate responder objects in the app.

- beginIgnoringInteractionEvents

Tells the receiver to suspend the handling of touch-related events.

- endIgnoringInteractionEvents

Tells the receiver to resume the handling of touch-related events.

ignoringInteractionEvents

A Boolean value that indicates whether the receiver is ignoring events initiated by touches on the screen.

applicationSupportsShakeToEdit

A Boolean value that determines whether shaking the device displays the undo-redo user interface.