2

正如我在这篇文章中推荐的那样,我已经实现了一个登录项。在辅助应用程序中,我使用NSWorkspace方法启动主应用程序launchApplication:showIcon:autolaunch:,发送YES到自动启动参数。

问题如下:我需要检查应用程序是否自动启动以不显示启动工具提示。我发现的唯一变体是[[NSUserDefaults standardUserDefaults] boolForKey:@"autolaunch"],它NO总是返回。

这个问题可以使用启动参数来解决——但不幸的是,沙盒也将它们切断了。

有什么我错过的吗?

4

1 回答 1

1

我使用以下代码隐藏启动的应用程序:

[[NSWorkspace sharedWorkspace] launchApplicationAtURL:[NSURL fileURLWithPath:appPath] options:NSWorkspaceLaunchAndHide configuration:nil error:nil];

如果你想设置额外的参数,你可以给方法一个自定义的配置字典。如果您在应用程序包中有启动器:

NSString *appPath=[[[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"MacOS/myApp"];
于 2013-03-15T16:33:00.480 回答