Search code examples
iosswiftuikituialertcontrolleruialertaction

No initializer for UIAlertAction (title, style, handler)


Dear Stackoverflowers,

Can any experts on Swift/UIKit see what I'm doing wrong in the following screenshot?

Xcode can't seem to find the convenience initializer for a UIAlertAction based on a title, style and handler, and I don't know of any other way to initialize a UIAlertAction. In practice, the handler won't be nil.

Thank you in advance,

Jamie

enter image description here


Solution

  • You are trying to pass Int to style param which is against swift rule. Try this out:

    let saveAction = UIAlertAction(title: "Save", style: UIAlertActionStyle.Default, handler: nil)