Re: Strings mangled on generalPasteboard
Re: Strings mangled on generalPasteboard
- Subject: Re: Strings mangled on generalPasteboard
- From: Jens Alfke <email@hidden>
- Date: Mon, 23 Nov 2009 08:59:05 -0800
On Nov 23, 2009, at 5:06 AM, Kevin Walzer wrote:
> If the dragtype is NSString or NSURL, this works as expected. The same data that is dragged comes out intact on the clipboard. However, file paths are inexplicably converted to file URL's, so that instead of "/Users/kevin/Desktop/foo.txt," I get "file://localhost/Users/kevin/Desktop/foo.txt."
I think that's because the code snippet you posted checks for URLs on the pasteboard before checking for file paths. When a file is on the pasteboard, both data flavors are present, and you're preferring to get the URL.
> I can't find a convenient method to convert file URL's back to simple path strings
-[NSURL path]
> Additionally, when I drag several files to the drag destination, only a single file URL is returned.
Again, you're checking for the URL flavor before the filenames flavor. Reverse the order of these tests.
The Cocoa Pasteboard API has the annoying limitation that there is no standard, public data type for multiple URLs. The de facto type is @"WebURLsWithTitlesPboardType" which is used by WebKit and Safari, but isn't declared in a header anywhere.
A useful tool when dealing with pasteboard integration issues like these is PasteboardPeeker — it's Apple sample code that you can download and build. It's a simple app with a window that you can drag stuff into, and it will dump all of the data types on the pasteboard and their (partial) contents.
—Jens_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden