我正在使用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();
})
}
现在,如果我收到多个通知,则每个通知都会显示警报。我的意思是,它出现在第一条消息中,我单击“确定”,它消失了,然后又出现在第二条消息中等等......这是正常行为。
我想要实现的是避免这一系列错误消息。其实我只关心第一个。有没有办法知道我的警报视图当前是否正在显示?像alert.isVisible
iOS上的东西UIAlertView
?