---
title: "addTarget(_:action:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uigesturerecognizer/addtarget(_:action:)"
---

# addTarget(_:action:)

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

## Declaration

```swift
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

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

### Related Documentation

- [init(target:action:)](uikit/uigesturerecognizer/init(target:action:).md)

### Adding and removing targets and actions

- [removeTarget(_:action:)](uikit/uigesturerecognizer/removetarget(_:action:).md)
