以编程方式关闭,重新启动,在沙盒可可应用程序中休眠

时间:2014-05-24 11:29:25

标签: macos cocoa sandbox shutdown entitlements

我的苹果沙箱和我的应用程序的功能有问题。该应用程序应该让我的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中提供的方法,如shutDown,restart或sleep,但它们不起作用。

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

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

非常感谢!

1 个答案:

答案 0 :(得分:0)

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

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

相关问题