addTarget(_:action:)
Adds a target and an action to a gesture-recognizer object.
Declaration
func addTarget(_ target: Any, action: Selector)Parameters
- target:
An object that is a recipient of action messages sent by the receiver when the represented gesture occurs.
nilis not a valid value. - action:
A selector identifying a method of a target to be invoked by the action message.
NULLis not a valid value.
Discussion
You may call this method multiple times to specify multiple target-action pairs. However, if you request to add a target-action pair that has already been added, then the request is ignored.