---
title: "init(title:message:preferredStyle:)"
framework: uikit
role: symbol
role_heading: Initializer
path: "uikit/uialertcontroller/init(title:message:preferredstyle:)"
---

# init(title:message:preferredStyle:)

Creates and returns a view controller for displaying an alert.

## Declaration

```swift
convenience init(title: String?, message: String?, preferredStyle: UIAlertController.Style)
```

## Parameters

- `title`: The title of the alert. Use this string to get people’s attention and communicate the reason for the alert.
- `message`: Descriptive text that provides additional details about the reason for the alert.
- `preferredStyle`: The style to use when presenting the alert controller. Use this parameter to configure the alert controller as an action sheet or as a modal alert.

## Return Value

Return Value An initialized alert controller object.

## Discussion

Discussion After creating the alert controller, configure any actions that you want people to be able to perform by calling the addAction(_:) method one or more times. When specifying a preferred style of UIAlertController.Style.alert, you may also configure one or more text fields to display in addition to the actions.
