Associates a target object and action method with the control.
- iOS 2.0+
- tvOS 9.0+
The target object—that is, the object whose
actionmethod is called. If you specify
nil, UIKit searches the responder chain for an object that responds to the specified action message and delivers the message to that object.
A selector identifying the action method to be called. You may specify a selector whose signature matches any of the signatures in Listing 1. This parameter must not be
A bitmask specifying the control-specific events for which the action method is called. Always specify at least one constant. For a list of possible constants, see
You may call this method multiple times to configure multiple targets and actions for the control. It is also safe to call this method multiple times with the same values for the
action parameters. The control maintains a list of its attached targets and actions along and the events each supports.
The control does not retain the object in the
target parameter. It is your responsibility to maintain a strong reference to the target object while it is attached to a control.
Specifying a value of
0 for the
control parameter does not prevent events from being sent to a previously registered
action method. To stop the delivery of events, always call the