Instance Method

sendAction(_:to:for:)

Calls the specified action method.

Declaration

func sendAction(_ action: Selector, to target: Any?, for event: UIEvent?)

Parameters

action

A selector identifying the action method to call. This parameter must not be nil.

target

The target object—that is, the object that implements the specified action. Specify nil if you want the app to search the responder chain for an object capable of performing the action.

event

The event that triggered the calling of the action method. You may specify nil for this parameter if you are calling this method directly, instead of in response to an event. For example, you might specify nil when changing the value of a control programmatically.

Discussion

This method takes the provided information and forwards it to the singleton UIApplication object for dispatching. If a valid target object was supplied, the app calls the action method on that target object. If the target object is nil, the app searches the responder chain for an object that defines the method.

Subclasses may override this method and use it to observe or modify the action dispatching behavior. Implementations should call super when they want to continue with the execution of the action method.

See Also

Triggering Actions

func sendActions(for: UIControl.Event)

Calls the action methods associated with the specified events.