Dragging files into other applications in cocoa OSX
<p>I'm trying to convert a windows application into OSX, everything is working now, except this small feature, the drag&amp;drop of files from my app into any other window that supports drops. Receiving drops it's easy, the problem is being the source of the data to drag.</p>

<p>My application only has 1 window with 1 view, I draw every control myself in there. So I simply extended my view like this <code>@interface NativeView : NSView &lt;NSDraggingSource, NSPasteboardItemDataProvider&gt;</code>.</p>

<p>Now the resto of the code I have so far should work in my opinion, but then again I don't know that much about cocoa and OSX:</p>

<pre><code>NSArray *fileList = [NSArray arrayWithObjects:&amp;pathList[0] count:pathList.size()];

NSPasteboard *pboard = [NSPasteboard pasteboardWithName: NSDragPboard];
[pboard declareTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:nil];
[pboard setPropertyList:fileList forType:NSFilenamesPboardType];

NSPasteboardItem *pbItem = [NSPasteboardItem new];
[pbItem setDataProvider:view forTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
[pbItem pasteboard:pboard provideDataForType:NSFilenamesPboardType];

NSDraggingItem *dragItem = [[NSDraggingItem alloc] initWithPasteboardWriter:pbItem];
[dragItem setDraggingFrame:NSMakeRect(0, 0, 10, 10)];


[view beginDraggingSessionWithItems:[NSArray arrayWithObjects:dragItem, nil] event:mouseEvent source:view];
</code></pre>

<p>The fileList is an array of <code>NSString*</code>. And where you see <code>view</code> it means the interface <code>NativeView</code>, it's implemented this way because this is coded within C++;</p>

<p>Currently, the code blocks when I try to set the <code>pasteboard</code> in the <code>pbItem</code>. I mean nothing else is executed past that line. I also tried to get rid of the <code>NSPasteboard</code>all together and use the <code>NSPasteboardItem</code>only, but I get a EXC_BAD_ACCESS running the last line: <code>beginDraggingSessionWithItems</code>.</p>

<p>I didn't find any examples online about dragging files,all that is is <code>NSImage</code>, and I have no use for that type of drag.</p>

<p>Any help will be welcome, thanks.</p>