diff --git a/Example/Example/ViewController.swift b/Example/Example/ViewController.swift index 235ae5e..ec4b5fd 100644 --- a/Example/Example/ViewController.swift +++ b/Example/Example/ViewController.swift @@ -33,11 +33,14 @@ class ViewController: UIViewController { // MARK: Alert @IBAction func showDefaultAlert(sender: UIButton) { +// UIAlertController.present(title: "title") { (action) -> () in +// UIAlertController.present(message: "message") { (action) -> () in UIAlertController.present(title: "title", message: "message", actionTitles: ["OK", "Cancel", "Destroy"]) { (action) -> () in print(action.title) } } + @IBAction func showAttributedAlert(sender: UIButton) { UIAlertController.present(title: "title", message: "message", attributedActionTitles: [("OK", .Default), ("Cancel", .Cancel), ("Destroy", .Destructive)]) { (action) -> () in print(action.title) diff --git a/Source/UIAlertControllerExtension.swift b/Source/UIAlertControllerExtension.swift index 274448e..2899b59 100644 --- a/Source/UIAlertControllerExtension.swift +++ b/Source/UIAlertControllerExtension.swift @@ -29,14 +29,14 @@ public typealias AttributedActionTitle = (title: String, style: UIAlertActionSty public extension UIAlertController { // Support Present UIAlertController from anywhere. It will be presented by Top Presented ViewController. - public class func present(style: UIAlertControllerStyle = .Alert, title: String?, message: String?, actionTitles: [String]?, handler: ActionHandler? = nil) -> UIAlertController { + public class func present(style: UIAlertControllerStyle = .Alert, title: String? = nil, message: String? = nil, actionTitles: [String]? = ["OK"], handler: ActionHandler? = nil) -> UIAlertController { // Force unwrap rootViewController let rootViewController = UIApplication.sharedApplication().delegate!.window!!.rootViewController! return self.presentFromViewController(rootViewController, style: style, title: title, message: message, actionTitles: actionTitles, handler: handler) } - public class func present(style: UIAlertControllerStyle = .Alert, title: String?, message: String?, attributedActionTitles: [AttributedActionTitle]?, handler: ActionHandler? = nil) -> UIAlertController { + public class func present(style: UIAlertControllerStyle = .Alert, title: String? = nil, message: String? = nil, attributedActionTitles: [AttributedActionTitle]?, handler: ActionHandler? = nil) -> UIAlertController { // Force unwrap rootViewController let rootViewController = UIApplication.sharedApplication().delegate!.window!!.rootViewController! @@ -72,11 +72,11 @@ public extension UIAlertController { // MARK: public extension UIViewController { - public func presentAlert(style: UIAlertControllerStyle = .Alert, title: String?, message: String?, actionTitles: [String]?, handler: ActionHandler? = nil) -> UIAlertController { + public func presentAlert(style: UIAlertControllerStyle = .Alert, title: String? = nil, message: String? = nil, actionTitles: [String]? = ["OK"], handler: ActionHandler? = nil) -> UIAlertController { return UIAlertController.presentFromViewController(self, style: style, title: title, message: message, actionTitles: actionTitles, handler: handler) } - public func presentAlert(style: UIAlertControllerStyle = .Alert, title: String?, message: String?, attributedActionTitles: [AttributedActionTitle]?, handler: ActionHandler? = nil) -> UIAlertController { + public func presentAlert(style: UIAlertControllerStyle = .Alert, title: String? = nil, message: String? = nil, attributedActionTitles: [AttributedActionTitle]?, handler: ActionHandler? = nil) -> UIAlertController { return UIAlertController.presentFromViewController(self, style: style, title: title, message: message, attributedActionTitles: attributedActionTitles, handler: handler) }