In my application, I have several scripts, each of which shows a different one UIAlertController, so I created a function to display this warning, but I can’t name myself. Function inside "okAction". I get this error:
Type value 'ViewController'has no member'doAction'
Here is the code:
func showAlertController( titleOfAlert: String, messageOfAlert : String, doAction : () )
{
let refreshAlert = UIAlertController(title: titleOfAlert, message: messageOfAlert, preferredStyle: .Alert)
let okAction = UIAlertAction(title: "Save", style: UIAlertActionStyle.Default) {
UIAlertAction in
self.doAction()
}
let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default) {
UIAlertAction in
}
refreshAlert.addAction(okAction)
refreshAlert.addAction(cancelAction)
self.presentViewController(refreshAlert, animated: true, completion: nil)
}
Here is one of the functions that I call:
func changeLabel1()
{
label.text = "FOR BUTTON 1"
}
How can I solve it?
source
share