4

I've been using dragImage:at:offset:event:pasteboard:source:slideBack: to show an image representation while dragging in previous projects but now that method is deprecated.

I've read that the supposed alternative is using beginDraggingSessionWithItems(…) but, the thing is I can't manage to do it properly.

This is my case:

-If I use dragPromisedFilesOfTypes(…), everything works ok. I drag my image to any folder, I can name the file as I want using namesOfPromisedFilesDroppedAtDestination(…), etc, BUT the dragged image is just an icon and I can't provide a dragging image since the aforementioned method is not longer available.

-If I use beginDraggingSessionWithItems(…) instead, I can provide a dragging image in mouseDragged(theEvent) method BUT then nothing happens when I drop the image into Finder. I could use draggingSession(_:endedAtPoint:operation:) method to save the image manually when the operation ends but this method doesn't have any info about drop destination url and namesOfPromisedFilesDroppedAtDestination(…) is not called in this case.

So, what am I missing? I guess this is a simple operation and shouldn't be that complicated. Apple documentation and googled tutorials are always using the deprecated method so I don't have any valid example to see where is my mistake. Please help.

NSGod
  • 22,699
  • 3
  • 58
  • 66
rmvz3
  • 1,133
  • 2
  • 16
  • 27
  • This post helped me very much. I hope it helps you as well. http://stackoverflow.com/questions/7781982/implement-drag-from-nsimageview-and-save-image-to-a-file/7830739#comment59964018_7830739 – rocky Mar 23 '16 at 22:08
  • Thank you for answering, Rocky. In fact, that's the way I used to do source dragging delegate. Unfortunately, that way is not longer allowed since the `dragimage...` function has been marked unavailable (at least using Swift and targeting 10.10). That's why I'm asking – rmvz3 Mar 25 '16 at 21:23
  • Same here. Couldn't find a solution for Swift. Has anybody looked into macOS 10.12? – Klaas Jul 29 '16 at 15:21
  • 1
    The "What's New in Cocoa" WWDC 2016 Session talks about the move of promissed drags to the new item based API. Starts around Minute 24:12. – Klaas Jul 29 '16 at 23:26

0 Answers0