2012-07-21 29 views
0

我必須以編程方式從我的Cocoa代碼中終止(而不是強制)一個應用程序。

其實,這裏是什麼樣子:
從我的Cocoa代碼中終止一個應用程序

​​


它非常好......但只雪豹和獅子。
在Leopard(我想支持)上啓動應用程序崩潰與此錯誤消息:

Exception Type: EXC_BREAKPOINT (SIGTRAP) 
Exception Codes: 0x0000000000000002, 0x0000000000000000 
Crashed Thread: 0 

Dyld Error Message: 
    Symbol not found: _OBJC_CLASS_$_NSRunningApplication 


我想這是因爲NSRunningApplication不是10.5 SDK的一部分......我該怎麼辦同樣沒有使用那個類?

+0

問題標題中使用的標籤是不必要的。 http://meta.stackexchange.com/questions/19190/should-questions-include-tags-in-their-titles – Adam 2012-07-21 17:32:06

回答

0

通過自己使用AppleScript解決:

-(BOOL) terminateiTunes { 
    NSAppleScript *closeiTunes = [[NSAppleScript alloc] initWithSource:@"tell application \"iTunes\" to quit"]; 
    [closeXcode executeAndReturnError:nil]; 
    return YES; 
} 
+0

將其標記爲正確答案 – TheAmateurProgrammer 2012-07-22 01:44:08