---
title: "alertView(_:clickedButtonAt:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uialertviewdelegate/alertview(_:clickedbuttonat:)"
---

# alertView(_:clickedButtonAt:)

Sent to the delegate when the user clicks a button on an alert view.

## Declaration

```swift
optional func alertView(_ alertView: UIAlertView, clickedButtonAt buttonIndex: Int)
```

## Parameters

- `alertView`: The alert view containing the button.
- `buttonIndex`: The index of the button that was clicked. The button indices start at 0.

## Discussion

Discussion The receiver is automatically dismissed after this method is invoked.
