Cocoa Sandbox: How to get permission to write multiple files or to a directory with NSSavePanel

appstore-sandbox, cocoa

Solution

You need NSOpenPanel.

NSOpenPanel * openPanel = [NSOpenPanel openPanel];
[openPanel setCanChooseFiles:NO];
[openPanel setCanChooseDirectories:YES];
[openPanel setAllowsMultipleSelection:NO];

Problem

So the NSSavePanel currently returns a file url complete with extension, and your app has permission to write to that file. Is there any way to allow the user to select a directory to write to? For example, if the app is exporting a dozen images at once, the names won't be specified by the user in advance.

Original source