警报操作处理程序
Alert action handler
我有调用处理程序的警报操作:
alert.addAction(UIAlertAction(title: "Call", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in UIApplication.sharedApplication().openURL(NSURL(string: "tel://number")!)}))
现在我想要一个调用我的函数的动作,像这样:
alert.addAction(UIAlertAction(title: "Call", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in myFunc() )}))
但是显示错误,我不知道如何解决这个问题。
求助!谢谢!
看起来你多了一个右括号。
替换下面一行
alert.addAction(UIAlertAction(title: "Call", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in myFunc() )}))
和
alert.addAction(UIAlertAction(title: "Call", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in myFunc()}))
我认为您使用了额外的右括号。
alert.addAction(UIAlertAction(title: "Call", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in myFunc()}))
我有调用处理程序的警报操作:
alert.addAction(UIAlertAction(title: "Call", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in UIApplication.sharedApplication().openURL(NSURL(string: "tel://number")!)}))
现在我想要一个调用我的函数的动作,像这样:
alert.addAction(UIAlertAction(title: "Call", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in myFunc() )}))
但是显示错误,我不知道如何解决这个问题。
求助!谢谢!
看起来你多了一个右括号。
替换下面一行
alert.addAction(UIAlertAction(title: "Call", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in myFunc() )}))
和
alert.addAction(UIAlertAction(title: "Call", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in myFunc()}))
我认为您使用了额外的右括号。
alert.addAction(UIAlertAction(title: "Call", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in myFunc()}))