My Mac app is sandboxed and I need to save a file. Where do I save this file? I can’t seem to find the specific place where this is allowed without using an open panel. This is how I do it on iOS:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [paths objectAtIndex:0];
What is the equivalent for the sandboxed directory on Mac?
That code snippet works on the Mac regardless of whether your application is sandboxed.
In a non-sandboxed Mac app,
pathwill refer to the Documents folder in your home: e.g./Users/username/Documents.In a sandboxed app, it refers to a folder within the app sandbox: e.g.
/Users/username/Library/Containers/com.yourcompany.YourApp/DocumentsSee the docs for details.