How would I create a UIAlertView in Swift?
Asked 07 September, 2021
Viewed 3.1K times
  • 56
Votes

I have been working to create a UIAlertView in Swift, but for some reason I can't get the statement right because I'm getting this error:


  

Could not find an overload for 'init' that accepts the supplied arguments

Here is how I have it written:

let button2Alert: UIAlertView = UIAlertView(title: "Title", message: "message",
                     delegate: self, cancelButtonTitle: "OK", otherButtonTitles: nil)

Then to call it I'm using:

button2Alert.show()

As of right now it is crashing and I just can't seem to get the syntax right.

30 Answer