Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MacOS沙箱在应用程序容器中写入文件_Macos_Read Write_Appstore Sandbox_Appcontainer - Fatal编程技术网

MacOS沙箱在应用程序容器中写入文件

MacOS沙箱在应用程序容器中写入文件,macos,read-write,appstore-sandbox,appcontainer,Macos,Read Write,Appstore Sandbox,Appcontainer,我正在尝试在我正在工作的应用程序上启用沙箱。尽管应用程序主要位于文件系统上,但为了创建、保存和加载用户文件,它不需要将文件放在应用程序容器之外。但通过启用沙箱,我无法再在应用程序中写入文件 有没有办法做到这一点 void DeterminePaths(const string &a_arg0) { string s; FSRef ref_num; char str_path[1024]; OSErr e = noErr; e =

我正在尝试在我正在工作的应用程序上启用沙箱。尽管应用程序主要位于文件系统上,但为了创建、保存和加载用户文件,它不需要将文件放在应用程序容器之外。但通过启用沙箱,我无法再在应用程序中写入文件

有没有办法做到这一点

void DeterminePaths(const string &a_arg0)
{
    string  s;
    FSRef   ref_num;
    char    str_path[1024];
    OSErr   e = noErr;

    e = FSFindFolder(kOnSystemDisk, kCurrentUserFolderType, false, &ref_num);
    e = FSRefMakePath(&ref_num, (UInt8*)str_path, 1024);
    s = string(str_path);

//Then I add on 's' the local directories for example s + "/silly_things"
}

<dict>
    <key>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.security.files.user-selected.read-write</key>
    <true/>
    <key>com.apple.security.network.client</key>
    <true/>
    <key>com.apple.security.network.server</key>
    <true/>
</dict>
void determinePath(常量字符串&a_arg0)
{
字符串s;
FSRef ref_num;
字符stru_路径[1024];
oserre=noErr;
e=FSFindFolder(kOnSystemDisk、kCurrentUserFolderType、false和ref_num);
e=FSRefMakePath(&ref_num,(UInt8*)str_path,1024);
s=字符串(str_路径);
//然后我在本地目录中添加“s”,例如s+“/silly\u things”
}
com.apple.security.app-sandbox
com.apple.security.files.user-selected.read-write
com.apple.security.network.client
com.apple.security.network.server

您可以发布您的权利文件吗?以及您用来获取容器目录的代码?提前谢谢,希望这有帮助!容器目录可通过NSFileManager获得。Sandbox不能很好地使用FSRef,请尝试使用NSURL。@mahaltertin谢谢你的评论,我实际上使用了另一种方法,数据可以保存在库中生成的应用程序文件夹中。