//
//  UIViewController+Alerts.swift
//  AwesomeLogin
//
//  Created by Evandro Harrison Hoffmann on 25/01/2017.
//  Copyright © 2017 CocoaPods. All rights reserved.
//

import UIKit

extension UIViewController {
    
    func showAlert(withTitle title: String? = nil, message: String?,  completion: (() -> ())? = nil, buttons: (UIAlertActionStyle, String, (() -> ())?)...) {
        
        guard let message = message, message.count > 0 else {
            return
        }
        
        if #available(iOS 8.0, *){
            let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
            
            for button in buttons {
                alertController.addAction(UIAlertAction(title: button.1, style: button.0) { (_: UIAlertAction!) in
                    if let completion = completion { completion() }
                    if let actionBlock = button.2 { actionBlock() }
                })
            }
            self.present(alertController, animated: true, completion: nil)
        }else {
            // Handle prior iOS Versions
            
        }
    }
    
}

//
//  UIViewController+Alerts.swift
//  AwesomeLogin
//
//  Created by Evandro Harrison Hoffmann on 25/01/2017.
//  Copyright © 2017 CocoaPods. All rights reserved.
//

import UIKit

extension UIViewController {
    
    public func showAlert(withTitle title: String? = nil, message: String?,  completion: (() -> ())? = nil, buttons: (UIAlertActionStyle, String, (() -> ())?)...) {
        
        guard let message = message, message.count > 0 else {
            return
        }
        
        if #available(iOS 8.0, *){
            let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
            
            for button in buttons {
                alertController.addAction(UIAlertAction(title: button.1, style: button.0) { (_: UIAlertAction!) in
                    if let completion = completion { completion() }
                    if let actionBlock = button.2 { actionBlock() }
                })
            }
            self.present(alertController, animated: true, completion: nil)
        }else {
            // Handle prior iOS Versions
            
        }
    }
    
}

--- 
+++ 
@@ -10,7 +10,7 @@
 
 extension UIViewController {
     
-    public func showAlert(withTitle title: String? = nil, message: String?,  completion: (() -> ())? = nil, buttons: (UIAlertActionStyle, String, (() -> ())?)...) {
+    func showAlert(withTitle title: String? = nil, message: String?,  completion: (() -> ())? = nil, buttons: (UIAlertActionStyle, String, (() -> ())?)...) {
         
         guard let message = message, message.count > 0 else {
             return
Set showAlert as not public so that we can have it also in Constants.
