<!--
{
  "availability" : [
    "iOS: 3.2.0 -",
    "iPadOS: 3.2.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIGestureRecognizer/init(target:action:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIGestureRecognizer(im)initWithTarget:action:"
  },
  "title" : "init(target:action:)"
}
-->

# init(target:action:)

Creates a gesture recognizer with a target and an action selector.

```
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` isn’t 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. `nil` isn’t a valid value.

## Return Value

An initialized instance of a concrete [`UIGestureRecognizer`](/documentation/UIKit/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:)`](/documentation/UIKit/UIGestureRecognizer/addTarget(_:action:)).

## See Also

[`-  removeTarget:action:`](/documentation/UIKit/UIGestureRecognizer/removeTarget(_:action:))

Removes a target and an action from a gesture-recognizer object.

[`-  addTarget:action:`](/documentation/UIKit/UIGestureRecognizer/addTarget(_:action:))

Adds a target and an action to a gesture-recognizer object.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)