Migrate to Swift 5.0

This commit is contained in:
Danny Moesch 2019-05-01 17:49:27 +02:00
parent e06413b348
commit f9c19b3ca4
26 changed files with 143 additions and 152 deletions

View file

@ -11,7 +11,7 @@ import UIKit
class SecurePasteboard {
public static let shared = SecurePasteboard()
private var backgroundTaskID = UIBackgroundTaskInvalid
private var backgroundTaskID = UIBackgroundTaskIdentifier.invalid
func copy(textToCopy: String?, expirationTime: Double = 45) {
// copy to the pasteboard
@ -23,21 +23,21 @@ class SecurePasteboard {
}
// exit the existing background task, if any
if backgroundTaskID != UIBackgroundTaskInvalid {
UIApplication.shared.endBackgroundTask(UIBackgroundTaskInvalid)
self.backgroundTaskID = UIBackgroundTaskInvalid
if backgroundTaskID != UIBackgroundTaskIdentifier.invalid {
UIApplication.shared.endBackgroundTask(UIBackgroundTaskIdentifier.invalid)
self.backgroundTaskID = UIBackgroundTaskIdentifier.invalid
}
backgroundTaskID = UIApplication.shared.beginBackgroundTask(expirationHandler: { [weak self] in
UIPasteboard.general.string = ""
UIApplication.shared.endBackgroundTask(UIBackgroundTaskInvalid)
self?.backgroundTaskID = UIBackgroundTaskInvalid
UIApplication.shared.endBackgroundTask(UIBackgroundTaskIdentifier.invalid)
self?.backgroundTaskID = UIBackgroundTaskIdentifier.invalid
})
DispatchQueue.global(qos: .utility).asyncAfter(deadline: .now() + expirationTime) { [weak self] in
UIPasteboard.general.string = ""
UIApplication.shared.endBackgroundTask(UIBackgroundTaskInvalid)
self?.backgroundTaskID = UIBackgroundTaskInvalid
UIApplication.shared.endBackgroundTask(UIBackgroundTaskIdentifier.invalid)
self?.backgroundTaskID = UIBackgroundTaskIdentifier.invalid
}
}

View file

@ -13,8 +13,8 @@ import passKit
extension Utils {
static func alert(title: String, message: String, controller: UIViewController, handler: ((UIAlertAction) -> Void)? = nil, completion: (() -> Void)? = nil) {
SVProgressHUD.dismiss()
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertActionStyle.default, handler: handler))
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "Ok".localize(), style: UIAlertAction.Style.default, handler: handler))
controller.present(alert, animated: true, completion: completion)
}
}