UIAlertView 使应用程序崩溃

UIAlertView Crashes App

我正在尝试在我的 Parse 应用程序上制作一个 UIAlertView,但出于某种原因,每次我 运行 它都会崩溃,我被带到 ApplicationDelegate,在那里我得到一个 SIGABRT。这是我的警报代码,我很确定我没有做错任何事,因为它以前工作过...是因为我正在从 Parse 将数据加载到表视图中吗?

func displayAlert(title: String, message: String) {
    var alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)

    alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { (action) ->    Void in


    }))

    presentViewController(alert, animated: true, completion: nil)
}

不确定你的问题是什么。您可以通过消除空闭包并尽可能缩短参数来简化代码,如下所示 (Xcode 7b6)。但我不认为这是你的问题。相反,您应该显示调用此函数的代码。

var alert = UIAlertController(title: title, message: message, preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
presentViewController(alert, animated: true, completion: nil)