AlertBuilderProtocol

public protocol AlertBuilderProtocol

A generic protocol to define common alert building functions.

  • Undocumented

    Declaration

    Swift

    typealias ActionBuilder = () -> UIAlertAction
  • Undocumented

    Declaration

    Swift

    typealias ActionHandler = (UIAlertAction) -> Void
  • Undocumented

    Declaration

    Swift

    typealias ShowCompletion = () -> Void
  • Specify a title for the alert.

    Declaration

    Swift

    func title(_ title: String) -> Self

    Parameters

    title

    the title.

    Return Value

    self for chaining.

  • Specify a message for the alert.

    Declaration

    Swift

    func message(_ message: String) -> Self

    Parameters

    message

    the message.

    Return Value

    self for chaining.

  • Add an action to the alert.

    Declaration

    Swift

    func addAction(builder: ActionBuilder) -> Self

    Parameters

    builder

    the builder to create an action.

    Return Value

    self for chaining.

  • Build an UIAlertController.

    Declaration

    Swift

    func build() -> UIAlertController

    Return Value

    an UIAlertController.

  • Show the alert.

    Declaration

    Swift

    @discardableResult
    func show(in context: UIViewController, animated: Bool, completion: ShowCompletion?) -> HideableAlert

    Parameters

    context

    the controller.

    animated

    showing with animation.

    completion

    completion after completed showing.

    Return Value

    an hideable alert.

  • Add an action with default style to the alert.

    Declaration

    Swift

    public func addAction(defaultType title: String, handler: ActionHandler? = nil) -> Self

    Parameters

    title

    the title of the action.

    handler

    the callback when selecting it.

    Return Value

    self for chaining.

  • Add an action with destructive style to the alert.

    Declaration

    Swift

    public func addAction(destructiveType title: String, handler: ActionHandler? = nil) -> Self

    Parameters

    title

    the title of the action.

    handler

    the callback when selecting it.

    Return Value

    self for chaining.

  • Add an action with cancel style to the alert.

    Declaration

    Swift

    public func addAction(cancelType title: String, handler: ActionHandler? = nil) -> Self

    Parameters

    title

    the title of the action.

    handler

    the callback when selecting it.

    Return Value

    self for chaining.

  • show(in:) Extension method

    Show the alert with animation and no completion.

    Declaration

    Swift

    @discardableResult
    public func show(in context: UIViewController) -> HideableAlert

    Parameters

    context

    the controller.

    Return Value

    an hideable alert.

  • show(in:animated:) Extension method

    Show the alert with no completion.

    Declaration

    Swift

    @discardableResult
    public func show(in context: UIViewController, animated: Bool) -> HideableAlert

    Parameters

    context

    the controller.

    animated

    showing with animation.

    Return Value

    an hideable alert.