Reputation: 677
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?""
Upvotes: 4
Views: 11350
Reputation: 1074
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)
Upvotes: 13