【问题标题】:Programmatically shutdown, restart, sleep in a sandboxed cocoa application在沙盒可可应用程序中以编程方式关闭、重启、休眠
【发布时间】:2014-05-24 11:29:25
【问题描述】:

我的苹果沙盒和我的应用程序的功能有问题。该应用程序应该让我的 Mac 进入睡眠状态,或者关闭或重新启动它。我使用“com.apple.security.temporary-exception.apple-events”作为值为“com.apple.finder”的沙盒的权利。我已经导入了 ScriptingBridge 并生成了一个 Finder.h 文件,我也将它包含在我的项目中,就像它在 https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ScriptingBridgeConcepts/UsingScriptingBridge/UsingScriptingBridge.html#//apple_ref/doc/uid/TP40006104-CH4-SW12 中提出的一样。

然后我尝试使用 Finder.h 提供的方法,例如关闭、重新启动或睡眠,但它们不起作用。

FinderApplication *theFinder = [SBApplication applicationWithBundleIdentifier:@"com.apple.finder"];
[theFinder shutDown];

谁能告诉我如何在沙盒应用中实现这些功能?

非常感谢!

【问题讨论】:

  • 您是否在控制台上收到任何消息?你的theFinder 是零吗?您进行了哪些诊断?
  • 如果您的应用要部署在 Mac App Store 中,您将无法通过临时例外中的 com.apple.finder 获得批准。另见stackoverflow.com/questions/21975699/…

标签: macos cocoa sandbox shutdown entitlements


【解决方案1】:

结帐https://developer.apple.com/library/mac/qa/qa1134/_index.html

本指南提供了您正在寻找的确切代码。这个我试过了,效果很好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-07
    • 1970-01-01
    相关资源
    最近更新 更多