我有一个 com.apple.security.assets.pictures.read-write entitlement 设置为 YES 的 sanboxed mac 应用程序。因此,我可以访问用户实际的/Users/username/Pictures 目录。
我想以编程方式获取此目录的路径,我该怎么做?
我目前执行以下操作,但它会导致沙箱容器图片位置。
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSPicturesDirectory, NSUserDomainMask, YES);
//this gets the pictures directory in sandbox container not the actual user Pictures directory
NSString *userPicturesPath = [paths objectAtIndex:0];
最佳答案
在我看来,沙箱容器 Pictures 目录只是 ~/Pictures
的符号链接(symbolic link)。所以我相信这正是你想要的。您可以通过在示例中的 userPicturesPath
上调用 stringByResolvingSymlinksInPath
来查看这一点。您可以看到这些文件实际上只是指向您的 $HOME
中相应文件的符号链接(symbolic link)。
关于objective-c - 如何在沙盒 mac 应用程序中获取用户的图片目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14378750/