Objective-C 使用 NSRunningApplication 终止,退出 iTunes

发布于 2024-10-27 23:29:42 字数 277 浏览 11 评论 0原文

我想从我的应用程序中退出 iTunes,这是我到目前为止的代码,但我收到错误 NSRunningApplication -未声明。

if ([closeiTunes state] == NSOnState) {
    [[NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.iTunes"] objectAtIndex:0] terminate];
}

有人可以帮忙吗?谢谢。

I want to quit iTunes from my app, this is the code i have so far, but i get the error NSRunningApplication -undeclared.

if ([closeiTunes state] == NSOnState) {
    [[NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.iTunes"] objectAtIndex:0] terminate];
}

Can anyone help? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枕梦 2024-11-03 23:29:42

NSRunningApplication 是一个仅在 10.6 SDK 中可用的类。将Base SDK设置为Mac OS X 10.6应该没有问题。

NSRunningApplication is a class that is only available in the 10.6 SDK. Set the Base SDK to Mac OS X 10.6 and there should be no problems.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文