2014-01-22 33 views
1

我需要在应用程序中显示警告无效的,如果应用程序是无效的,我需要使用NSUserNotification发出警报否则我将用一个简单sheetModal警告对话框。我如何知道应用程序是处于活动状态还是非活动状态?即用户正在积极使用该应用程序或使用其他应用程序?如何检测,如果应用程序是在Mac应用

我需要复制相同的警报系统在Xcode,如果Xcode是积极它显示的Xcode窗口中的消息否则将发布UserNotification。

回答

1

您应该NSApplicaion阅读文档。

在这里面,你会看到

isActive

Returns a Boolean value indicating whether this is the active application. 

- (BOOL)isActive 
Return Value 
YES if this is the active application; NO otherwise. 
相关问题