---
title: UIAlertController
framework: uikit
role: symbol
role_heading: Class
path: uikit/uialertcontroller
---

# UIAlertController

An object that displays an alert message.

## Declaration

```swift
@MainActor class UIAlertController
```

## Mentioned in

Getting the user’s attention with alerts and action sheets

## Overview

Overview Use this class to configure alerts and action sheets with the message that you want to display and the actions from which to choose. After configuring the alert controller with the actions and style you want, present it using the present(_:animated:completion:) method. UIKit displays alerts and action sheets modally over your app’s content. In addition to displaying a message to a user, you can associate actions with your alert controller to give people a way to respond. For each action you add using the addAction(_:) method, the alert controller configures a button with the action details. When a person taps that action, the alert controller executes the block you provided when creating the action object. The following code shows how to configure an alert with a single action. When configuring an alert with the UIAlertController.Style.alert style, you can also add text fields to the alert interface. The alert controller lets you provide a block for configuring your text fields prior to display. The alert controller maintains a reference to each text field so that you can access its value later. important: The UIAlertController class is intended to be used as-is and doesn’t support subclassing. The view hierarchy for this class is private and must not be modified.

## Topics

### Creating an alert controller

- [init(title:message:preferredStyle:)](uikit/uialertcontroller/init(title:message:preferredstyle:).md)

### Configuring the alert

- [title](uikit/uialertcontroller/title.md)
- [message](uikit/uialertcontroller/message.md)
- [preferredStyle](uikit/uialertcontroller/preferredstyle.md)
- [UIAlertController.Style](uikit/uialertcontroller/style.md)

### Configuring the user actions

- [addAction(_:)](uikit/uialertcontroller/addaction(_:).md)
- [actions](uikit/uialertcontroller/actions.md)
- [preferredAction](uikit/uialertcontroller/preferredaction.md)

### Configuring text fields

- [addTextField(configurationHandler:)](uikit/uialertcontroller/addtextfield(configurationhandler:).md)
- [textFields](uikit/uialertcontroller/textfields.md)

### Configuring alert severity

- [severity](uikit/uialertcontroller/severity.md)
- [UIAlertControllerSeverity](uikit/uialertcontrollerseverity.md)

## Relationships

### Inherits From

- [UIViewController](uikit/uiviewcontroller.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [Copyable](swift/copyable.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Escapable](swift/escapable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSExtensionRequestHandling](foundation/nsextensionrequesthandling.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSTouchBarProvider](appkit/nstouchbarprovider.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [UIActivityItemsConfigurationProviding](uikit/uiactivityitemsconfigurationproviding.md)
- [UIAppearanceContainer](uikit/uiappearancecontainer.md)
- [UIContentContainer](uikit/uicontentcontainer.md)
- [UIFocusEnvironment](uikit/uifocusenvironment.md)
- [UIPasteConfigurationSupporting](uikit/uipasteconfigurationsupporting.md)
- [UIResponderStandardEditActions](uikit/uiresponderstandardeditactions.md)
- [UISpringLoadedInteractionSupporting](uikit/uispringloadedinteractionsupporting.md)
- [UIStateRestoring](uikit/uistaterestoring.md)
- [UITraitChangeObservable](uikit/uitraitchangeobservable-67e94.md)
- [UITraitEnvironment](uikit/uitraitenvironment.md)
- [UIUserActivityRestoring](uikit/uiuseractivityrestoring.md)

## See Also

### Alerts

- [Getting the user’s attention with alerts and action sheets](uikit/getting-the-user-s-attention-with-alerts-and-action-sheets.md)
- [UIAlertAction](uikit/uialertaction.md)
