Being that UIAlertView
is now deprecated, I wanted to provide an answer to future coders that come across this.
Instead of UIAlertView
, I would use UIAlertController
like so:
@IBAction func showAlert(_ sender: Any) {
let alert = UIAlertController(title: "My Alert", message: "This is my alert", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.default, handler: {(action) in
alert.dismiss(animated: true, completion: nil)
}))
self.present(alert,animated:true, completion:nil)
}