class Service: UIViewController {
static func showError(_ message:String) {
// Create new Alert
let dialogMessage = UIAlertController(title: "Error", message: message, preferredStyle: .alert)
// Create OK button with action handler
let ok = UIAlertAction(title: "OK", style: .default, handler: { (action) -> Void in
print("Ok button tapped")
})
//Add OK button to a dialog message
dialogMessage.addAction(ok)
// Present Alert to
self.present(dialogMessage , animated: true, completion: nil)
}
}
why i get error in this line:
self.present(dialogMessage , animated: true, completion: nil)
the error:
Instance member 'present' cannot be used on type 'Service'
why?