I am trying to write a function that displays a UIAlertController
when a UITextField
is left empty. I used the following example to display the message. At this stage, I get the following error:
Use of unresolved identifier 'self'
The code I have is below.
func displayMyAlertMessage(userMessage: String){
let myAlert = UIAlertController(title: "Alert", message: userMessage, preferredStyle: UIAlertController.Style.alert)
let okAction = UIAlertAction(title: "Ok", style: UIAlertAction.Style.default, handler: nil)
myAlert.addAction(okAction)
self.present(myAlert, animated: true, completion: nil)
}