从我的Cocoa代码中终止一个应用程序
问题描述:
我必须以编程方式从我的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的一部分......我该怎么办同样没有使用那个类?
答
通过自己使用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
问题标题中使用的标签是不必要的。 http://meta.stackexchange.com/questions/19190/should-questions-include-tags-in-their-titles – Adam 2012-07-21 17:32:06