UIAlertController in static method giving error: extra argument animated in cell

Viewed 551

I wish to create a static method which I can place in a utility class which would launch a UIAlertController. However, I am getting the following error:

"extra argument animated in cell"

static func simpleAlertBox1(msg : String) -> Void{
    let alertController = UIAlertController(title: "Alert!", message: msg, preferredStyle: .actionSheet)
    let defaultAction = UIAlertAction(title: "OK", style: .default, handler: nil)
    alertController.addAction(defaultAction)
    present(alertController, animated: true, completion: nil)// error is being generated here
}

I tried this but it still gave me the same error:

presentViewController(alertController, animated: true, completion: nil)

but if I were to remove the static, then it works fine.

2 Answers
Related