Skip to content

Instantly share code, notes, and snippets.

@foxicode
Last active September 13, 2020 05:04
Show Gist options
  • Select an option

  • Save foxicode/f66b2c4a1e8d4655719971d4c17d2fb2 to your computer and use it in GitHub Desktop.

Select an option

Save foxicode/f66b2c4a1e8d4655719971d4c17d2fb2 to your computer and use it in GitHub Desktop.
Showing localised warning or error
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