objective c - OS X Login helper app thinks app is already running -
i'm working on implementing helper app launch main, non-sandboxed app upon user login.
i want make sure that, in event there instance of app running @ login, helper app not launch second instance of app, , terminates appropriately.
when i'm testing this, , looking @ console's output, see helper app thinks there app instance running, if there not. so, helper app quit without launching main app. have idea on why helper app may think there existing app instance, though there not?
#import "appdelegate.h" @implementation appdelegate - (void)applicationdidfinishlaunching:(nsnotification *)notification { //check if we're running app. if are, quit helper app. if ([nsrunningapplication runningapplicationswithbundleidentifier:@"com.me.myapp"]) { nslog(@"we're running app already, we're going quit."); } //otherwise, launch app, quit helper app. else { [[nsworkspace sharedworkspace] launchapplication:@"my app"]; } [[nsapplication sharedapplication] terminate:self]; } @end
runningapplicationswithbundleidentifier: not return nil, return empty array, comparison evaluates yes.
quote docs:
return value
array of nsrunningapplications, or empty array if no applications match bundle identifier.
Comments
Post a Comment