gpt4 book ai didi

cocoa - NSSavePanel 和沙箱

转载 作者:行者123 更新时间:2023-12-03 16:06:23 28 4
gpt4 key购买 nike

我在理解新的 Lion's Sandbox 时遇到一些问题。

我知道 Lion 包含一个名为 Powerbox 的可信守护进程,其工作是代表沙盒应用程序显示和控制打开/保存对话框。

喜欢Code Signing And Application Sandboxing Guide说:

Any time an application running inside a sandbox invokes an NSOpenPanel or NSSavePanel dialog, rather than showing the panels directly, AppKit automatically asks the Powerbox to present the dialog. From a developer perspective, there are no code changes required in terms of how these panels are used; this process is fully transparent.

After the user selects a set of files or directories, the Powerbox uses new functionality in the sandbox kernel module to expand the invoking application's sandbox to allow access to the selected files. By the time the application code queries the panel for the returned URLs or filenames, it already has permission to access those files, and can continue to use the files through almost any API it already uses.

好的。我使用这段代码做了一些实际测试:

NSSavePanel *savePanel = [NSSavePanel savePanel];
savePanel.delegate = self;

savePanel.directoryURL = ...;
savePanel.nameFieldStringValue = ...;

[savePanel beginSheetModalForWindow:self.window
completionHandler:^(NSInteger returnCode) {
/* the completion handler */
}];

奇怪的是,在完成处理程序之前调用的 NSOpenSavePanelDelegate 方法无权访问文件系统上的文件

这是正确的吗?

但如果是这样,委托(delegate)的方法如 panel:validateURL:error: 就变得毫无用处!

您能帮我更详细地解释一下应用程序和 Powerbox 之间的连接吗?

最佳答案

联系 Apple 后,我可以确认 Rob Keniger 所写的内容:NSOpenSavePanelDelegate 方法无法访问沙盒应用程序中的文件系统。

关于cocoa - NSSavePanel 和沙箱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6844383/

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