An action that can be taken when the user taps a button in an alert.


class UIAlertAction : NSObject


You use this class to configure information about a single action, including the title to display in the button, any styling information, and a handler to execute when the user taps the button. After creating an alert action object, add it to a UIAlertController object before displaying the corresponding alert to the user.


Creating an Alert Action

init(title: String?, style: UIAlertAction.Style, handler: ((UIAlertAction) -> Void)?)

Create and return an action with the specified title and behavior.

Getting the Action’s Attributes

var title: String?

The title of the action’s button.

var style: UIAlertAction.Style

The style that is applied to the action’s button.

var isEnabled: Bool

A Boolean value indicating whether the action is currently enabled.


enum UIAlertAction.Style

Styles to apply to action buttons in an alert.


Inherits From

See Also


Getting the User's Attention with Alerts and Action Sheets

Present important information to the user or prompt the user about an important choice.

class UIAlertController

An object that displays an alert message to the user.