<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: 13.1.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CarPlay",
  "identifier" : "/documentation/CarPlay/CPAlertAction",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "CarPlay"
    ],
    "preciseIdentifier" : "c:objc(cs)CPAlertAction"
  },
  "title" : "CPAlertAction"
}
-->

# CPAlertAction

An object that encapsulates an action the user can perform on an action sheet or alert.

```
class CPAlertAction
```

## Overview

Use an alert action to display a button on an alert. The combination of the alert and the action styles determines the appearance of the action button. To perform an action after the user taps the button, provide a block to the action’s [`handler`](/documentation/CarPlay/CPAlertAction/handler) property.

## Topics

### Creating an Alert Action

[`-  initWithTitle:style:handler:`](/documentation/CarPlay/CPAlertAction/init(title:style:handler:))

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

### Getting the Title

[`title`](/documentation/CarPlay/CPAlertAction/title)

The action button’s title.

### Getting the Action Style

[`style`](/documentation/CarPlay/CPAlertAction/style-swift.property)

The display style for the action button.

[`Style`](/documentation/CarPlay/CPAlertAction/Style-swift.enum)

Display styles for an alert’s action button.

### Getting the Action Handler

[`handler`](/documentation/CarPlay/CPAlertAction/handler)

The closure that CarPlay invokes after the user taps the action button.

[`CPAlertActionHandler`](/documentation/CarPlay/CPAlertActionHandler)

The declaration for an alert action handler.

### Initializers

[`-  initWithTitle:color:handler:`](/documentation/CarPlay/CPAlertAction/init(title:color:handler:))

### Instance Properties

[`color`](/documentation/CarPlay/CPAlertAction/color)

## Relationships

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Equatable`](/documentation/Swift/Equatable)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

---

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)