simon.d
simon.d

Reputation: 2531

Drag multiple files to sandboxed app

I'm building a simple app that allows the user to drag a list of video files from Finder into my app. I was reading the Apple docs about dragging files and it says this:

Important. Although you can support dragging file paths, in general, you should avoid doing so unless you are certain that the destination app will never be run in an app sandbox. If you use an NSString, OS X has no way to know whether that string should be interpreted as a path; thus, OS X does not expand the destination app’s sandbox to allow access to the file or directory at that location. Instead, use an NSURL, a bookmark, or a filename pasteboard type.

Unfortunately the docs also say that when using NSURL, you can only drag one file at a time. My app is sandboxed.

Am I missing something? Thanks!

Upvotes: 3

Views: 832

Answers (1)

brynbodayle
brynbodayle

Reputation: 6626

NSFilenamesPboardType is your solution. It supports the dragging of multiple files while operating within the app sandbox.

The quote you give supports that:

Instead, use an NSURL, a bookmark, or a filename pasteboard type.

See the Apple doc here for information on how to receive the file links from NSFilenamesPboardType.

Receiving Drag Operations

Upvotes: 4

Related Questions