addTarget(_:action:for:)
Registers a target-action pair for the specified control events.
Declaration
func addTarget(_ target: Any?, action: Selector, for controlEvents: NSControl.Events)Parameters
- target:
The object to receive the action message. Pass
nilto send the action up the responder chain. - action:
The selector to invoke on
targetwhen the specified events occur. This parameter can’t benil. The selector may include the sender, the event, or both as parameters, in that order. - controlEvents:
A bit mask of Events values specifying which events initiate the action.
Discussion
You can call this method multiple times to register additional target-action pairs for the same or different events. You can also register multiple targets or multiple actions for the same event. The control holds a weak reference to each registered target.