For example,
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler:{ (x:UIAlertAction) in
...
will give a "Cannot find initializer with..." error.
But if I say UIAlertAction!
or UIAlertAction?
instead of just UIAlertAction
, it works. Why is this?
The types of these variables are all declared already in the Cocoa API. You must match them. A thing and an Optional wrapping that thing are not a match; they are two completely different types.
On the other hand, when types are known you can just omit them. So the easiest thing is for you to change x:UIAlertAction
to simple x
or even _
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments