I posted this question about dragging content from OS X Finder into an NSTableView. This all works nicely now. However, if I want to drag URLs from a browser address bar into my app, I first need to drag them to the desktop (where they appear as a .webloc file) and then drag them into my app.
Is there a way to directly drag them from the browser address bar into my app, without having to drag them to the desktop first?
I tried registering kUTTypeURL but this doesn’t seem to work as dragged URLs bounce back to their origin:
[[self sourcesTableView] registerForDraggedTypes:[NSArray arrayWithObjects: (NSString*)kUTTypeFileURL, (NSString*)kUTTypeURL, nil]];
In my accepted answer to your other question, the code I provided specifically restricts the URLs that your app can accept to file URLs:
Note the options dictionary containing a boolean
YESfor theNSPasteboardURLReadingFileURLsOnlyKey.If you want to accept any URL, just do this:
Or even better, you can require that you’ll accept any URL as long as it is of a particular type, in this case an image: