Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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];
like image 302
AmaltasCoder Avatar asked Jan 17 '13 12:01

AmaltasCoder


People also ask

What is sandbox folder Mac?

This folder holds all local information for the app, like your app preferences. If you don't ever give a sandboxed app access to additional files or folders (eg: by choosing extra locations in file handling dialogs), then you can be sure that everything the app stores on your Mac is kept in its sandbox.


1 Answers

It seems to me that the sandbox container Pictures directory is just an symlink to ~/Pictures. So I believe this is exactly what you want. You can see this by calling stringByResolvingSymlinksInPath on the userPicturesPath in your example. You can see that these files are really just symlinks to the corresponding files in your $HOMEScreenshot

like image 181
Keith Smiley Avatar answered Nov 15 '22 04:11

Keith Smiley