Initializer

init(target:action:)

Initializes an allocated gesture-recognizer object with a target and an action selector.

Declaration

init(target: Any?, action: Selector?)

Parameters

target

An object that is the recipient of action messages sent by the receiver when it recognizes a gesture. nil is not a valid value.

action

A selector that identifies the method implemented by the target to handle the gesture recognized by the receiver. The action selector must conform to the signature described in the class overview. NULL is not a valid value.

Return Value

An initialized instance of a concrete UIGestureRecognizer subclass.

Discussion

This method is the designated initializer. After creating the gesture recognizer, you may associate other target-action pairs with it by calling addTarget(_:action:).

See Also