Skip to content

Commit 51ed6b0

Browse files
authored
Fixes warnings about APIs deprecated in iOS8 (#53)
* removes warnings about APIs deprecated in iOS8
1 parent d856108 commit 51ed6b0

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

AuthSamples/SwiftSample/ViewController.swift

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,13 @@ final class ViewController: UIViewController, UITextFieldDelegate {
342342
providerListLabel.text = providers?.joined(separator: ", ")
343343
if let photoURL = user?.photoURL {
344344
lastPhotoURL = photoURL
345-
DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.background).async {
345+
let queue: DispatchQueue
346+
if #available(iOS 8.0, *) {
347+
queue = DispatchQueue.global(qos: .background)
348+
} else {
349+
queue = DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.background)
350+
}
351+
queue.async {
346352
if let imageData = try? Data(contentsOf: photoURL) {
347353
let image = UIImage(data: imageData)
348354
DispatchQueue.main.async {
@@ -382,8 +388,22 @@ final class ViewController: UIViewController, UITextFieldDelegate {
382388
}
383389

384390
fileprivate func showAlert(title: String, message: String? = "") {
385-
UIAlertView(title: title, message: message ?? "(NULL)", delegate: nil, cancelButtonTitle: nil,
386-
otherButtonTitles: "OK").show()
391+
if #available(iOS 8.0, *) {
392+
let alertController =
393+
UIAlertController(title: title, message: message, preferredStyle: .alert)
394+
alertController.addAction(UIAlertAction(title: "OK",
395+
style: .default,
396+
handler: { (UIAlertAction) in
397+
alertController.dismiss(animated: true, completion: nil)
398+
}))
399+
self.present(alertController, animated: true, completion: nil)
400+
} else {
401+
UIAlertView(title: title,
402+
message: message ?? "(NULL)",
403+
delegate: nil,
404+
cancelButtonTitle: nil,
405+
otherButtonTitles: "OK").show()
406+
}
387407
}
388408

389409
private func ifNoError(_ error: Error?, execute: () -> Void) {

0 commit comments

Comments
 (0)