Add this code in any Class (As UIViewController extension) as shown below
extension UIViewController {
    func alert(message: String, title: String ) {
        let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
        let OKAction = UIAlertAction(title: "OK", style: .default, handler: nil)
        alertController.addAction(OKAction)
        self.present(alertController, animated: true, completion: nil)
    }
}
and call it anywhere(In  Any ViewController) as shown below,
self.alert(message: "Some message", title: "Title of Alert")
No comments:
Post a Comment