title: How to force kill another application in cocoa Mac OS X 10.5
body: <p>I've this task, from my application i need to <strong>kill</strong> another my application, the problem is that the <strong>other application has a Termination <em>Confirm Dialog</em></strong> (there is no critical data to save, only confirmation of user intent to quit).</p>
  
  <ul>
  <li><p>On 10.6+ you will use:</p>
  
  <pre><code>bool TerminatedAtLeastOne = false;
  
  // For OS X &gt;= 10.6 NSWorkspace has the nifty runningApplications-method.
  if ([NSRunningApplication respondsToSelector:@selector(runningApplicationsWithBundleIdentifier:)]) {
      for (NSRunningApplication *app in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.company.applicationName"]) {
          [app forceTerminate];
          TerminatedAtLeastOne = true;
      }
      return TerminatedAtLeastOne;
  }
  </code></pre></li>
  <li><p>but on &lt;10.6 this commonly used Apple Event:</p>
  
  <pre><code>// If that didn‘t work either... then try using the apple event method, also works for OS X &lt; 10.6.
  AppleEvent event = {typeNull, nil};
  const char *bundleIDString = "com.company.applicationName";
  
  OSStatus result = AEBuildAppleEvent(kCoreEventClass, kAEQuitApplication, typeApplicationBundleID, bundleIDString, strlen(bundleIDString), kAutoGenerateReturnID, kAnyTransactionID, &amp;event, NULL, "");
  
  if (result == noErr) {
      result = AESendMessage(&amp;event, NULL, kAENoReply|kAEAlwaysInteract, kAEDefaultTimeout);
      AEDisposeDesc(&amp;event);
  }
  return result == noErr;
  </code></pre>
  
  <p>can't Force Quit!!!</p></li>
  </ul>
  
  <p>So what can you use?</p>