diff options
author | Zsika Phillip <protocol86@users.noreply.github.com> | 2017-06-01 13:53:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-01 13:53:49 -0700 |
commit | 51ed6b0a4fbdea5db5f57dcdd50e13463d652485 (patch) | |
tree | 7cff618f26be8b21dc97b8cf89d58d39ec5345b6 /AuthSamples | |
parent | d85610816f02ea8bc0f22f6bd531cff330f4b874 (diff) |
Fixes warnings about APIs deprecated in iOS8 (#53)
* removes warnings about APIs deprecated in iOS8
Diffstat (limited to 'AuthSamples')
-rw-r--r-- | AuthSamples/SwiftSample/ViewController.swift | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/AuthSamples/SwiftSample/ViewController.swift b/AuthSamples/SwiftSample/ViewController.swift index a65cbd9..d52641f 100644 --- a/AuthSamples/SwiftSample/ViewController.swift +++ b/AuthSamples/SwiftSample/ViewController.swift @@ -342,7 +342,13 @@ final class ViewController: UIViewController, UITextFieldDelegate { providerListLabel.text = providers?.joined(separator: ", ") if let photoURL = user?.photoURL { lastPhotoURL = photoURL - DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.background).async { + let queue: DispatchQueue + if #available(iOS 8.0, *) { + queue = DispatchQueue.global(qos: .background) + } else { + queue = DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.background) + } + queue.async { if let imageData = try? Data(contentsOf: photoURL) { let image = UIImage(data: imageData) DispatchQueue.main.async { @@ -382,8 +388,22 @@ final class ViewController: UIViewController, UITextFieldDelegate { } fileprivate func showAlert(title: String, message: String? = "") { - UIAlertView(title: title, message: message ?? "(NULL)", delegate: nil, cancelButtonTitle: nil, - otherButtonTitles: "OK").show() + if #available(iOS 8.0, *) { + let alertController = + UIAlertController(title: title, message: message, preferredStyle: .alert) + alertController.addAction(UIAlertAction(title: "OK", + style: .default, + handler: { (UIAlertAction) in + alertController.dismiss(animated: true, completion: nil) + })) + self.present(alertController, animated: true, completion: nil) + } else { + UIAlertView(title: title, + message: message ?? "(NULL)", + delegate: nil, + cancelButtonTitle: nil, + otherButtonTitles: "OK").show() + } } private func ifNoError(_ error: Error?, execute: () -> Void) { |