simplify alert code

This commit is contained in:
Bob Sun 2017-02-16 00:54:42 +08:00
parent 5ed3629c52
commit edfd8c97a7
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
7 changed files with 21 additions and 40 deletions

View file

@ -8,6 +8,7 @@
import Foundation
import SwiftyUserDefaults
import UIKit
class Utils {
static func removeFileIfExists(atPath path: String) {
@ -50,6 +51,13 @@ class Utils {
return randomString
}
static func alert(title: String, message: String, controller: UIViewController, completion: (() -> Void)?) {
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
controller.present(alert, animated: true, completion: completion)
}
}
// https://gist.github.com/NikolaiRuhe/eeb135d20c84a7097516