I want to make an alert dialog showing up with messages and here's my code in ViewController.swift:
func showErrorAlert(title: String , msg: String){
let alert = UIAlertController(title: title, message: msg, preferredStyle: .Alert)
let action = UIAlertAction(title: "OK", style: .Default, handler: nil)
alert.addAction(action)
presentedViewController(alert, animated: true, completion: nil)
}
The last line is giving me an error:
"Cannot call value of non-function type "UIViewController?""
EDIT: For Swift 3, change it to
present(alert, animated: false, completion: nil)
You called the wrong function.
Should be
presentViewController(alert, animated: true, completion: nil)
Instead of presentedViewController(alert, animated: true, completion: nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With