MDCAlertAction

@interface MDCAlertAction : NSObject <NSCopying, UIAccessibilityIdentification>

MDCAlertAction is passed to an MDCAlertController to add a button to the alert dialog.

  • A convenience method for adding actions that will be rendered as low emphasis buttons at the bottom of an alert controller.

    Declaration

    Objective-C

    + (nonnull instancetype)actionWithTitle:(nonnull NSString *)title
                                    handler:(MDCActionHandler _Nullable)handler;

    Parameters

    title

    The title of the button shown on the alert dialog.

    handler

    A block to execute when the user selects the action.

    Return Value

    An initialized MDCActionAlert object.

  • An action that renders at the bottom of an alert controller as a button of the given emphasis.

    Declaration

    Objective-C

    + (nonnull instancetype)actionWithTitle:(nonnull NSString *)title
                                   emphasis:(MDCActionEmphasis)emphasis
                                    handler:(MDCActionHandler _Nullable)handler;

    Parameters

    title

    The title of the button shown on the alert dialog.

    emphasis

    The emphasis of the button that will be rendered in the alert dialog. Unthemed actions will render all emphases as text. Apply themers to the alert to achieve different appearance for different emphases.

    handler

    A block to execute when the user selects the action.

    Return Value

    An initialized MDCActionAlert object.

  • Alert actions must be created with actionWithTitle:handler:

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • Title of the button shown on the alert dialog.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) NSString *title;
  • The MDCActionEmphasis emphasis of the button that will be rendered for the action.

    Declaration

    Objective-C

    @property (readonly, nonatomic) MDCActionEmphasis emphasis;
  • The @c accessibilityIdentifier for the view associated with this action.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable)
        NSString *accessibilityIdentifier;