【发布时间】:2016-07-09 12:24:16
【问题描述】:
我正在使用NSAlert 在我的应用程序的主屏幕上显示错误消息。
基本上,NSAlert 是我的主视图控制器的属性
class ViewController: NSViewController {
var alert: NSAlert?
...
}
当我收到一些通知时,我会显示一些消息
func operationDidFail(notification: NSNotification)
{
dispatch_async(dispatch_get_main_queue(), {
self.alert = NSAlert()
self.alert.messageText = "Operation failed"
alert.runModal();
})
}
现在,如果我收到多个通知,则每个通知都会显示警报。我的意思是,它出现在第一条消息中,我点击“确定”,它消失了,然后再次出现在第二条消息中等等......这是正常行为。
我想要实现的是避免这一系列错误消息。其实我只关心第一个。
有没有办法知道我的警报视图当前是否正在显示?
类似于 iOS 的 UIAlertView 上的 alert.isVisible ?
【问题讨论】: