Instance Property

preferredAction

The preferred action for the user to take from an alert.

Declaration

@property(nonatomic, strong) UIAlertAction *preferredAction;

Discussion

The preferred action is relevant for the UIAlertControllerStyleAlert 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 addAction: method is a programmer error.

The default value of this property is nil.

See Also

Configuring the User Actions

- addAction:

Attaches an action object to the alert or action sheet.

actions

The actions that the user can take in response to the alert or action sheet.