• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Strings mangled on generalPasteboard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strings mangled on generalPasteboard


  • Subject: Re: Strings mangled on generalPasteboard
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 23 Nov 2009 08:54:34 -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

  • Follow-Ups:
    • Re: Strings mangled on generalPasteboard
      • From: Kevin Walzer <email@hidden>
    • Re: Strings mangled on generalPasteboard
      • From: mmalc Crawford <email@hidden>
References: 
 >Strings mangled on generalPasteboard (From: Kevin Walzer <email@hidden>)

  • Prev by Date: Re: How can I not block hotkey from other apps
  • Next by Date: Re: Strings mangled on generalPasteboard
  • Previous by thread: Strings mangled on generalPasteboard
  • Next by thread: Re: Strings mangled on generalPasteboard
  • Index(es):
    • Date
    • Thread