Fix RxExample warnings

This commit is contained in:
freak4pc 2020-09-19 22:10:35 +03:00 committed by Shai Mishali
parent e5586918c6
commit c4326d4814
3 changed files with 15 additions and 17 deletions

View File

@ -33,13 +33,3 @@ extension String {
return numberFormatter.number(from: self)?.doubleValue
}
}
func showAlert(_ message: String) {
#if os(iOS)
UIAlertView(title: "RxExample", message: message, delegate: nil, cancelButtonTitle: "OK").show()
#elseif os(macOS)
let alert = NSAlert()
alert.messageText = message
alert.runModal()
#endif
}

View File

@ -83,8 +83,18 @@ class GitHubSearchRepositoriesViewController: ViewController, UITableViewDelegat
.map { $0.isLimitExceeded }
.distinctUntilChanged()
.filter { $0 }
.drive(onNext: { n in
showAlert("Exceeded limit of 10 non authenticated requests per minute for GitHub API. Please wait a minute. :(\nhttps://developer.github.com/v3/#rate-limiting")
.drive(onNext: { [weak self] n in
guard let self = self else { return }
let message = "Exceeded limit of 10 non authenticated requests per minute for GitHub API. Please wait a minute. :(\nhttps://developer.github.com/v3/#rate-limiting"
#if os(iOS)
self.present(UIAlertController(title: "RxExample", message: message, preferredStyle: .alert), animated: true)
#elseif os(macOS)
let alert = NSAlert()
alert.messageText = message
alert.runModal()
#endif
})
.disposed(by: disposeBag)

View File

@ -62,14 +62,12 @@ class SimpleValidationViewController : ViewController {
}
func showAlert() {
let alertView = UIAlertView(
let alert = UIAlertController(
title: "RxExample",
message: "This is wonderful",
delegate: nil,
cancelButtonTitle: "OK"
preferredStyle: .alert
)
alertView.show()
show(alert, sender: nil)
}
}