我在閱讀關於Mac應用沙箱的內容,並且想知道當用戶在NSOpenPanel或NSSavePanel中選擇一個文件夾時究竟發生了什麼。該「App Sandbox Design Guide」給出了下面的例子:當用戶選擇一個文件夾時,Mac沙盒應用程序可以訪問什麼?
When a user of your app specifies they want to use a file or a folder, the system adds the associated path to your app’s sandbox. Say, for example, a user drags the
~/Documents
folder onto your app’s Dock tile (or onto your app’s Finder icon, or into an open window of your app), thereby indicating they want to use that folder. In response, the system makes the~/Documents
folder, its contents, and its subfolders available to your app.
這不是很清楚,我什麼的「內容」在這裏的意思。這限於查看文件夾中的文件而無法讀取這些文件中的內容嗎?抑或這只是意味着該應用程序將能夠讀取的(遞歸)的文檔文件夾內的任何文件(因此它可以,例如,閱讀這兩個~/Documents/Foo.txt
和~/Documents/Bar/Baz.txt
)?寫操作(寫入現有文件,刪除一個文件或創建一個新文件或文件夾)如何?
此外,如果您啓用了書籤的權利,你可以使用 - [NSURL bookmarkDataWithOptions:includingResourceValuesForKeys:relativeToURL:錯誤:]保存這些權限後。見https://developer.apple.com/library/mac/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW16。 – AriX