1

I have an alert action with calling handler:

alert.addAction(UIAlertAction(title: "Call", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in UIApplication.sharedApplication().openURL(NSURL(string: "tel://number")!)}))

Now I want one more action that will call my function, something like this:

alert.addAction(UIAlertAction(title: "Call", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in myFunc() )}))

But it shows an error and I don't know how to solve this problem.

Help! Thanks!

aaisataev
  • 1,533
  • 3
  • 20
  • 35

2 Answers2

4

Looks like you had an extra closing parentheses.

Replace the following line

alert.addAction(UIAlertAction(title: "Call", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in myFunc() )}))

with

alert.addAction(UIAlertAction(title: "Call", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in myFunc()}))
Balaji Kondalrayal
  • 1,718
  • 2
  • 19
  • 38
0

I think you had used extra closing bracket.

alert.addAction(UIAlertAction(title: "Call", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in myFunc()}))
darshan
  • 1,105
  • 1
  • 14
  • 29