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,643
  • 3
  • 22
  • 38

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,743
  • 3
  • 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,115
  • 1
  • 14
  • 29