<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIAlertController/init(title:message:preferredStyle:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIAlertController(cm)alertControllerWithTitle:message:preferredStyle:"
  },
  "title" : "init(title:message:preferredStyle:)"
}
-->

# init(title:message:preferredStyle:)

Creates and returns a view controller for displaying an alert.

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

An initialized alert controller object.

## Discussion

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

---

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)