如何防止在应用程序启动osx时显示窗口

问题描述:

我正在学习OS X的Objective-C和编程应用程序.我想给自己写一个简单的通知程序,应该以这种方式工作:

I am learning Objective-C and programming applications for OS X. I want to write myself a simple notifier, which should work this way:

  • 连接到网站并检查是否有新内容(我已经覆盖了内容)
  • 显示带有诸如忽略",访问网站"之类的操作按钮的窗口(这也很容易)

我想,我会将我的应用添加到启动中,如果网站上没有任何更改,则只需终止它即可.但是,如果有新内容,带有操作按钮的窗口将在应用程序检查之前弹出,并且窗口将快速闪烁.我该如何预防?

I thought, that I will add my app to startup and if there are no changes on the website - just terminate it. But the window with action buttons will pop up before application checks, if there is a new content and window will flash quickly. How do I prevent that?

是否有更好的方法来创建这样的东西?例如,不是在启动过程中运行我的应用程序-运行守护进程,而是每24小时检查一次网站,然后显示一个窗口?我该怎么办?

Is there a better way to create something like this? For example instead of running my application during startup - running a daemon, that will check the website every 24 hours and then display the window? How can I do that?

最近,我阅读了立即开始开发Mac Apps ,所以我可能仍然缺少明显的东西.

Recently, I read Start Developing Mac Apps Today, so I might be still missing something obvious.

选择NSWindow,然后在启动时关闭可见".

Select NSWindow and just turn off Visible At Launch.

如果要显示该窗口,请按以下步骤手动进行操作.

If you want to show the window, do it manually as follows.

- (void)applicationWillFinishLaunching:(NSNotification *)notification {
    /* Do whatever necessary before the window appears */
    [window setIsVisible:YES];
}

我个人从来没有打开启动时可见"开关.

Personally, I never have the Visible-At-Launch switch on.