[英]How to get the user's Pictures directory in sandboxed mac application?
I have a sanboxed mac app with com.apple.security.assets.pictures.read-write entitlement set to YES. 我有一个sanboxed mac app,com.apple.security.assets.pictures.read-write权利设置为YES。 Hence, I can access users actual /Users/username/Pictures directory.
因此,我可以访问用户的实际/用户/用户名/图片目录。
I would like to get the path of this directory programmatically, how can I do that? 我想以编程方式获取此目录的路径,我该怎么做?
I currently do the following but it results in the sandbox container Pictures location. 我目前执行以下操作,但它会导致沙箱容器图片位置。
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];
It seems to me that the sandbox container Pictures directory is just an symlink to ~/Pictures
. 在我看来沙盒容器Pictures目录只是
~/Pictures
的符号链接。 So I believe this is exactly what you want. 所以我相信这正是你想要的。 You can see this by calling
stringByResolvingSymlinksInPath
on the userPicturesPath
in your example. 您可以通过调用看到这个
stringByResolvingSymlinksInPath
在userPicturesPath
在你的榜样。 You can see that these files are really just symlinks to the corresponding files in your $HOME
您可以看到这些文件实际上只是
$HOME
相应文件的符号链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.