<!--
{
  "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/addTarget(_:action:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIGestureRecognizer(im)addTarget:action:"
  },
  "title" : "addTarget(_:action:)"
}
-->

# addTarget(_:action:)

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

```
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. `nil` is not a valid value.

`action`

A selector identifying a method of a target to be invoked by the action message. `NULL` is 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.

## See Also

[`init(target:action:)`](/documentation/UIKit/UIGestureRecognizer/init(target:action:))

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



---

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)