Created
September 5, 2016 19:50
-
-
Save 0ber/9ac1fde8777ead27e4c4c4ba2a0d9352 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol SwiftyAlertController { | |
static func actionSheet(title: String?, message: String?, actions: [EasyAlertControllerAction]) -> UIAlertController | |
static func alert(title: String?, message: String?, actions: [EasyAlertControllerAction]) -> UIAlertController | |
} | |
extension SwiftyAlertController where Self: UIAlertController { | |
static func actionSheet(title: String? = nil, message: String? = nil, actions: [EasyAlertControllerAction]) -> UIAlertController { | |
let alert = UIAlertController(title: title, message: message, preferredStyle: .ActionSheet) | |
actions.forEach { alert.addAction($0.action) } | |
return alert | |
} | |
static func alert(title: String? = nil, message: String? = nil, actions: [EasyAlertControllerAction]) -> UIAlertController { | |
let alert = UIAlertController(title: title, message: message, preferredStyle: .Alert) | |
actions.forEach { alert.addAction($0.action) } | |
return alert | |
} | |
} | |
extension UIAlertController: SwiftyAlertController {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment