Created
December 7, 2017 10:42
-
-
Save khawajafarooq/93ad5c7909e458609578ef1dc306ec4f to your computer and use it in GitHub Desktop.
Error extension to support UIAlertController
This file contains 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 | |
/// Extending error to make it alertable | |
extension Error { | |
/// displays alert from source controller | |
func alert(with controller: UIViewController) { | |
let alertController = UIAlertController(title: "Oops ❗️", message: "\(self)", preferredStyle: .alert) | |
let okAction = UIAlertAction(title: "OK", style: .default, handler: nil) | |
alertController.addAction(okAction) | |
controller.present(alertController, animated: true, completion: nil) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment