Anyway.
I've got a better version now (and I don't know why I didn't do this the first time either); use AppleScript to quit the old version and then continue on the app's merry way. I put this in my main.m file, before NSApplicationMain():
#ifdef DEBUG
NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
NSArray *launchedApplications = [workspace launchedApplications];
for (NSDictionary *junk in launchedApplications) {
if ([@"com.flyingmeat.VoodooPad_Pro" isEqualToString:[junk objectForKey:@"NSApplicationBundleIdentifier"]]) {
NSLog(@"It's already running you moron");
system("/usr/bin/osascript -e 'tell app \"VoodooPad Pro\" to quit'");
sleep(1.5f); // let the quit actually happen.
}
}
#endif
NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
NSArray *launchedApplications = [workspace launchedApplications];
for (NSDictionary *junk in launchedApplications) {
if ([@"com.flyingmeat.VoodooPad_Pro" isEqualToString:[junk objectForKey:@"NSApplicationBundleIdentifier"]]) {
NSLog(@"It's already running you moron");
system("/usr/bin/osascript -e 'tell app \"VoodooPad Pro\" to quit'");
sleep(1.5f); // let the quit actually happen.
}
}
#endif
Yes yes yes, using system() is bad. I know. It's only ever run on my desktop though.