---
title: "addButton(withTitle:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uialertview/addbutton(withtitle:)"
---

# addButton(withTitle:)

Adds a button to the receiver with the given title.

## Declaration

```swift
func addButton(withTitle title: String?) -> Int
```

## Parameters

- `title`: The title of the new button.

## Return Value

Return Value The index of the new button. Button indices start at 0 and increase in the order they are added.

## Discussion

Discussion Adding too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see Temporary Views.

## See Also

### Related Documentation

- [message](uikit/uialertview/message.md)

### Configuring buttons

- [numberOfButtons](uikit/uialertview/numberofbuttons.md)
- [buttonTitle(at:)](uikit/uialertview/buttontitle(at:).md)
- [textField(at:)](uikit/uialertview/textfield(at:).md)
- [cancelButtonIndex](uikit/uialertview/cancelbuttonindex.md)
- [firstOtherButtonIndex](uikit/uialertview/firstotherbuttonindex.md)
