[+] Encapsulate sending an alert

This commit is contained in:
Hykilpikonna
2021-01-22 14:54:00 -05:00
parent a3dfff1e38
commit 9ee1132d7d
+15
View File
@@ -7,7 +7,9 @@
import Foundation import Foundation
import CryptoKit import CryptoKit
import UIKit
/// Date manipulations
extension Date extension Date
{ {
/// Add toString to Date /// Add toString to Date
@@ -79,6 +81,7 @@ extension TimeInterval
} }
} }
/// Apply like Kotlin /// Apply like Kotlin
protocol HasApply {} protocol HasApply {}
extension HasApply extension HasApply
@@ -93,6 +96,7 @@ extension HasApply
extension Alarm: HasApply {} extension Alarm: HasApply {}
extension Alarms: HasApply {} extension Alarms: HasApply {}
/// Hashing /// Hashing
extension Digest extension Digest
{ {
@@ -104,3 +108,14 @@ extension String
{ {
var sha256: String { SHA256.hash(data: self.data(using: .utf8)!).b64 } var sha256: String { SHA256.hash(data: self.data(using: .utf8)!).b64 }
} }
/// Alerts
extension UIViewController
{
func alert(_ title: String, _ message: String)
{
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
self.present(alert, animated: true, completion: nil)
}
}