2

I have implemented a login item as I was recommended in this post. In the helper app I launch the main app using NSWorkspace method launchApplication:showIcon:autolaunch:, sending YES to autolaunch parameter.

The problem is in following: I need to check if the applications was autolaunched not to show start tooltip. The only variant I found is [[NSUserDefaults standardUserDefaults] boolForKey:@"autolaunch"], and it returns NO always.

The problem could be solved using launch arguments - but sandbox, unfortunately, cuts them too.

Is there something I missed?

Community
  • 1
  • 1
pAK-76
  • 305
  • 3
  • 8
  • fixed. Didn't notice the button earlier, thanx for help) – pAK-76 Oct 25 '12 at 17:32
  • I don't think I get your question - can you rephrase what you're trying to check for the launched app? – Jay Oct 26 '12 at 17:43
  • I need to check if it was autolaunched (after system startup) or not. When I start my main app with helper I send Boolean parameter to NSWorkspace - and I need to retrieve it in the main application. – pAK-76 Oct 30 '12 at 12:18

1 Answers1

1

I use the following code to hide the launched application:

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

If you want to set additional parameters, you can give the method a custom configuration dictionary. If you have the launcher inside the application bundle:

NSString *appPath=[[[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"MacOS/myApp"];
Nickkk
  • 2,261
  • 1
  • 25
  • 34