【发布时间】:2017-06-07 15:50:11
【问题描述】:
我正在编写一个 FinderSync 扩展,它将一个项目放在上下文菜单中。当我右键单击时,我希望菜单项的标题根据所选文件的内容进行更改。但是,当我尝试使用Data(contentsOf: selectedUrl) 读取内容时,会引发以下错误:
Error Domain=NSCocoaErrorDomain Code=257 "无法打开文件“Some File.png”,因为您没有查看权限。" UserInfo={NSFilePath=/Users/Shared/MySyncExtension Documents/Some File.png, NSUnderlyingError=0x61800004cf00 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not allowed"}}
如果我添加或删除沙盒,这不会改变。
先前的研究
-
The file couldn’t be opened because you don’t have permission to view it
- 编译器一直设置为默认值
-
Read and Write access for FinderSync extension in a sandboxed environment
- 授权已启用。此外,这会在沙盒关闭的情况下表现出来。
-
"File could not open because you do not have permission to view it." | Official Apple Support Communities
- 文件的权限显示“每个人”都具有“只读”访问权限
【问题讨论】:
标签: swift cocoa sandbox nsfilemanager findersync