I just want to drop files onto my Dock icon!
I’ve spent days reading post after post after post after post that purported to solve the mystery of how to hook up the magic pieces just right to enable files to be dropped onto your app’s icon.
However, since none of the links I trawled included both up-to-date and complete examples, I figured I’d put one together for whoever has to fight this battle in the future. Caveat emptor, but really, it’s as simple as hell, so you can’t go wrong.
DockDrop.zip, 19KB, version 1.0 - GitHub
If you’re interested, the nitty gritty magic bits that need be plumbed up just right:
- Make sure your delegate implements
NSApplicationDelegate, and that it is set as the delegate ofNSApp.- Implement
application:openFile:in said delegate.- Ensure you have a proper
CFBundleDocumentTypesentry in your app’s Info.plist (see the example’s plist).
Speaking of dock shenanigans, John Winter, the Dropzone author, wrote about how the Chrome browser launches itself without bouncing the dock icon. It’s not for every app, but it’s perfect for Dropzone. If you want to be able to drag a file onto your dock icon, this trick may also be for you.
I’ve spent days reading
