Skip to content

Instantly share code, notes, and snippets.

@PetreVane
Last active October 9, 2019 18:38
Show Gist options
  • Save PetreVane/ff111701617ee04ce1b8ea62e63decd0 to your computer and use it in GitHub Desktop.
Save PetreVane/ff111701617ee04ce1b8ea62e63decd0 to your computer and use it in GitHub Desktop.
class ErrorManager {
static func showError(message: String, on viewController: UIViewController?, dismissAction: ((UIAlertAction) -> Void)? = nil) {
weak var currentViewController = viewController
DispatchQueue.main.async {
let alertController = UIAlertController(title: "Error", message: message, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "Dismiss", style: .default, handler: dismissAction))
currentViewController?.present(alertController, animated: true)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment