An action displayed on an alert as a button.


class CPAlertAction : NSObject


Use an alert action to display a button on an alert. The combination of the alert and action styles determine the appearance of the action button. To perform an action after the user taps the button, provide a block to the action’s handler property.


Creating an Alert Action

init(title: String, style: CPAlertAction.Style, handler: CPAlertActionHandler)

Creates an alert action with a title, style, and action handler.

Getting the Title

var title: String

The action button's title.

Getting the Action Style

var style: CPAlertAction.Style

The display style for the action button.

enum CPAlertAction.Style

Display styles for an alert’s action button.

Getting the Action Handler

var handler: CPAlertActionHandler

The block invoked after the user taps the action button.

typealias CPAlertActionHandler

The declaration for an alert action handler.


Inherits From

See Also

Action Sheets and Alerts

class CPActionSheetTemplate

A template for displaying an action sheet on the CarPlay screen.

class CPAlertTemplate

A template for displaying alerts on the CarPlay screen.