The preferred action for the user to take from an alert.
- iOS 9.0+
- Mac Catalyst 13.0+Beta
- tvOS 9.0+
The preferred action is relevant for the
UIAlert style only; it is not used by action sheets. When you specify a preferred action, the alert controller highlights the text of that action to give it emphasis. (If the alert also contains a cancel button, the preferred action receives the highlighting instead of the cancel button.) If the iOS device is connected to a physical keyboard, pressing the Return key triggers the preferred action.
The action object you assign to this property must have already been added to the alert controller’s list of actions. Assigning an object to this property before adding it with the
add method is a programmer error.
The default value of this property is