NSSavePanel和沙箱 [英] NSSavePanel and the Sandbox

查看:234
本文介绍了NSSavePanel和沙箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在了解新狮友的沙盒时遇到一些问题。

I have some problems understanding the new Lion's Sandbox.

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

I know that Lion includes a trusted daemon process called Powerbox whose job is to present and control open/save dialog boxes on behalf of sandboxed applications.

代码签名和应用程序沙盒指南说: p>

Like the Code Signing And Application Sandboxing Guide says:


无论何时在沙箱中运行的应用程序调用NSOpenPanel或NSSavePanel对话框,AppKit都不会直接显示面板,对话。从开发人员的角度来看,这些面板的使用方式不需要更改代码;这个过程是完全透明的。

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.

在用户选择一组文件或目录之后,Powerbox使用沙箱内核模块中的新功能来扩展调用应用程序的沙箱,以允许访问所选文件。当应用程序代码查询面板返回的URL或文件名时,它已经具有访问这些文件的权限,并且可以通过几乎已经使用的任何API继续使用这些文件。

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.

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

Ok. I did some practical tests using this code:

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

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

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


$ b <

The strange thing is that the NSOpenSavePanelDelegate method's, that are called BEFORE the completion handler, do not have access to files on the filesystem.

这是否正确?

但是如果是这样,委托的方法,如 panel:validateURL:error:就没用了!

But if so, the delegate's methods like panel:validateURL:error: becomes useless!

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

Can you help me explaining in more detail the connections between the app and Powerbox?

推荐答案

>方法无法访问沙盒应用程序中的文件系统。

After contacting Apple, I can confirm what Rob Keniger wrote: NSOpenSavePanelDelegate method's don't have access to the filesystem in sandboxed applications.

这篇关于NSSavePanel和沙箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆