Cocoa应用程序完成启动 [英] Cocoa Application Finished Launch

查看:86
本文介绍了Cocoa应用程序完成启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以告诉Cocoa应用程序(如Safari)是否已经完成启动并能够响应?
我知道在实际代码中使用代理很容易,但这是不可能的。

Is there any way to tell if a Cocoa application, such as Safari, has finished launching and able to respond? I know it's easy to do using delegates within the actual code but that isn't possible for what I'm doing.

感谢

推荐答案

查看NSWorkspace和NSWorkspaceDidLaunchApplicationNotification。像这样:

Check out NSWorkspace and NSWorkspaceDidLaunchApplicationNotification. Something like this:

[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(appDidLaunch:) name:NSWorkspaceDidLaunchApplicationNotification object:nil]

传递给指定方法的NSNotification对象将包含有关启动的应用程序的信息,路径等。例如:

The NSNotification object passed to the specified method will contain information about what application launched, its path, etc. For example:

- (void)appDidLaunch:(NSNotification*)note
{
    NSLog(@"app launched: %@", [note userInfo]);
}

编辑:这仅适用于桌面可可应用程序 - 是不可能在Cocoa Touch。只是澄清了。

this is for desktop cocoa applications only - I'm fairly sure this is impossible in Cocoa Touch. Just clarifying that.

这篇关于Cocoa应用程序完成启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆