Last active
September 13, 2020 05:04
-
-
Save foxicode/f66b2c4a1e8d4655719971d4c17d2fb2 to your computer and use it in GitHub Desktop.
Showing localised warning or error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| extension UIViewController { | |
| func show(error: String) { | |
| let alert = UIAlertController(title: NSLocalizedString("error", comment: ""), message: error, preferredStyle: .alert) | |
| alert.addAction(UIAlertAction(title: NSLocalizedString("ok", comment: ""), style: .cancel, handler: nil)) | |
| present(alert, animated: true, completion: nil) | |
| } | |
| func show(warning: String) { | |
| let alert = UIAlertController(title: NSLocalizedString("warning", comment: ""), message: warning, preferredStyle: .alert) | |
| alert.addAction(UIAlertAction(title: NSLocalizedString("ok", comment: ""), style: .cancel, handler: nil)) | |
| present(alert, animated: true, completion: nil) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment