gpt4 book ai didi

macos - 如何在 cocoa 中重新启动 Finder 应用程序?

转载 作者:行者123 更新时间:2023-12-03 17:53:46 27 4
gpt4 key购买 nike

我需要在具有沙箱支持的 cocoa 应用程序中重新启动我的查找应用程序。我已经尝试过

尝试 1:

[[NSTask launchedTaskWithLaunchPath:@"/usr/bin/killall"
arguments:[NSArray arrayWithObjects:@"Finder", nil]] waitUntilExit];

沙箱不支持它。它显示killall:警告:kill -TERM 7833:不允许操作错误。

尝试 2:

NSDictionary *error = [NSDictionary dictionary];
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:@"tell application \"System Events\" to restart"];
[script executeAndReturnError:&error];

沙箱中也不允许这样做。

是否可以在我的应用程序中重新启动 Finder 应用程序并提供沙盒支持?

最佳答案

看看App Sandbox Temporary Exception Entitlements

With App Sandbox you cannot send Apple events to other apps unless you configure a scripting-targets entitlement or an apple-events temporary exception entitlement.

授权 key

  • com.apple.security.temporary-exception.apple-events

能力

  • 允许将 Apple 事件发送到一个或多个目标应用。

关于macos - 如何在 cocoa 中重新启动 Finder 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17210732/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com