I have the following code repeated in many of my view controllers
. I would like to refactor it into a global class/view controller. However, I still want it to be s
Its just simple Just create a new NSObject class and Do the following
class WrapperClass: NSObject
{
class func BasicAlert(_ title : String, message : String, view:UIViewController)
{
let alert = UIAlertController(title:title, message: message, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
view.present(alert, animated: true, completion: nil)
}
}
Usage
WrapperClass.BasicAlert("Error", message: "Bluetooth Headset is Not Connected, Please Retry", view: self)