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) -> SelfParameters
titlethe title.
Return Value
self for chaining.
-
Specify a message for the alert.
Declaration
Swift
func message(_ message: String) -> SelfParameters
messagethe message.
Return Value
self for chaining.
-
Add an action to the alert.
Declaration
Swift
func addAction(builder: ActionBuilder) -> SelfParameters
builderthe builder to create an action.
Return Value
self for chaining.
-
Build an UIAlertController.
Declaration
Swift
func build() -> UIAlertControllerReturn Value
an UIAlertController.
-
Show the alert.
Declaration
Swift
@discardableResult func show(in context: UIViewController, animated: Bool, completion: ShowCompletion?) -> HideableAlertParameters
contextthe controller.
animatedshowing with animation.
completioncompletion after completed showing.
Return Value
an hideable alert.
-
addAction(defaultType:Extension methodhandler: ) Add an action with default style to the alert.
Declaration
Swift
public func addAction(defaultType title: String, handler: ActionHandler? = nil) -> SelfParameters
titlethe title of the action.
handlerthe callback when selecting it.
Return Value
self for chaining.
-
addAction(destructiveType:Extension methodhandler: ) Add an action with destructive style to the alert.
Declaration
Swift
public func addAction(destructiveType title: String, handler: ActionHandler? = nil) -> SelfParameters
titlethe title of the action.
handlerthe callback when selecting it.
Return Value
self for chaining.
-
addAction(cancelType:Extension methodhandler: ) Add an action with cancel style to the alert.
Declaration
Swift
public func addAction(cancelType title: String, handler: ActionHandler? = nil) -> SelfParameters
titlethe title of the action.
handlerthe 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) -> HideableAlertParameters
contextthe controller.
Return Value
an hideable alert.
-
show(in:Extension methodanimated: ) Show the alert with no completion.
Declaration
Swift
@discardableResult public func show(in context: UIViewController, animated: Bool) -> HideableAlertParameters
contextthe controller.
animatedshowing with animation.
Return Value
an hideable alert.
View on GitHub
Install in Dash
AlertBuilderProtocol Protocol Reference