我是 IOS 应用程序开发和 swift 的初学者。我现在正在尝试我们 UIAlertController.UIAlertAction 向我询问三个参数。第三个是闭包。如果我想将我的预定义函数传递给这个参数,我该怎么办?这是我的代码。我在这些代码之前编写了 func ask()。该函数也没有错误。但是以下代码在声明 UIAlertAction 时显示名为“表达式类型不明确而没有更多上下文”的错误。我正在制作游戏教程https://www.hackingwithswift.com/read/2/5/from-outlets-to-actions-ibaction-and-string-interpolation。
let a:UIAlertController = UIAlertController(title: title, message: "Your score is \(scores)", preferredStyle: .Alert)
let b:UIAlertAction=UIAlertAction(title: "ok", style: .Default, handler:ask)
a.addAction(b)
presentViewController(a, animated: true, completion: nil)