UIAlertController

extension UIAlertController
  • Adds a UIAlertAction, initialized with a title, style, and completion handler.

    Declaration

    Swift

    @discardableResult
    public func addAction(title: String?, style: UIAlertAction.Style = .default, handler: ((UIAlertAction) -> Void)? = nil) -> Self

    Parameters

    title

    The text to use for the action title.

    style

    The style to use for the action (optional, defaults to .default).

    handler

    A closure to execute when the user selects the action (optional, defaults to nil).

    Return Value

    self

  • Creates a UIAlertController instance, styled as an action sheet.

    Declaration

    Swift

    public static func actionSheet(title: String? = nil, message: String? = nil) -> UIAlertController

    Parameters

    title

    The title for the controller (optional, defaults to nil).

    message

    The message for the controller (optional, defaults to nil).

    Return Value

    A UIAlertController instance, styled as an action sheet.

  • Creates a UIAlertController instance, styled as an alert.

    Declaration

    Swift

    public static func alert(title: String? = nil, message: String? = nil) -> UIAlertController

    Parameters

    title

    The title for the controller (optional, defaults to nil).

    message

    The message for the controller (optional, defaults to nil).

    Return Value

    A UIAlertController instance, styled as an alert.