Re: dealing with NSURLPasteboardType
Re: dealing with NSURLPasteboardType
- Subject: Re: dealing with NSURLPasteboardType
- From: Matt Neuburg <email@hidden>
- Date: Tue, 28 May 2002 14:20:13 -0700
Hi, Matt (or Rollie - that should keep us distinct) -
>
>>> What do I do when I'm handed an NSURLPasteboardType? I don't see how to
>
>>> get
>
>>> the NSURL off the pasteboard. No NSPasteboard method returns an NSURL. I
>
>>> can get a property list by asking for an NSString, but that's not an
>
>>> NSURL
>
>>> and I don't see how to convert it to one. I can get an NSData but that's
>
>>> not an NSURL either and I don't see how to convert it to one. Thx - m.
>
>
>
> Right you are - thank you. Just what I was after. (Thinks: And the Apple
>
> folks wonder why people swear at the documentation?! I spent four hours
>
> looking for this and never found it - and never would have, without having
>
> it shown to me by another human being.) m.
>
>
A bit late responding to this message, but I don't understand why this was
>
so hard
I'm glad you're interested. Naturally I wish you'd asked earlier when the
affair was fresh in my mind, but I think I can reconstruct. This was my
first receive-a-drag-and-drop coding, so I started with the Drag and Drop
topic and in particular the Dragging Destination and Receiving Drag
Operations where I learned that it was all about the dragged types. This
raised the question "types of what?", but luckily there was example code
there that suggested I was talking to an NSPasteboard, so I opened the
NSPasteboard documentation.
At this point my problem was that I had no idea what I'd be receiving (I
was going to drag an icon from the Finder), but the example had shown me
that I could ask for a list of the types actually arriving, so I wrote some
code that did just that - I used [NSPasteboard types] to get an array and
logged it so I could study what I'd gotten.
I was a little mystified because much of what showed up in the resulting
array was not stuff that matched the names of the "common pasteboard data
types". But even more mystifying - and this is the really important thing -
is that the documentation at this point doesn't make any connection between
the "common pasteboard data types" and the verbs you can use to consult
what's on the pasteboard. In other words, how do I get what's on the
pasteboard off the pasteboard? I'm told that I can read data with things
like dataForType, propertyListForType, stringForType - but which of those
should I use if the type is an NSColorPboardType, which should I use if
it's an NSFileContentsPboardType,and so on? In other words, the information
on this page is all disconnected - we're told the names of some types, but
not (a) what datatype they return or (b) what verb should be used to
extract that data. It seems to me that the table of common pasteboard data
types should be rewritten with a couple of extra columns to show this. It
is very annoying being told that these are data types and not to be told
what datatype each data type is! Let alone, how to extract it properly.
>
I did a search on the ADC site for "NSURL pasteboard" and the referenced
>
document was the first hit.
I'm not on the ADC site - I'm at home on my computer. When I say "the
documentation" I mean how the supplied book (as it were) is written.
>
Doing a search for NSURLPboardType also gets you to the NSURLAdditions
>
document
Not so! I did a Find within Project Builder and all I got was this line of
the NSPasteboard header file:
APPKIT_EXTERN NSString *NSURLPboardType;
This told me nothing new.
>
And if you look in the topics hierarchy, under the Copying and Pasting topic
But I'm not copying or pasting! I'm doing a drag and drop. Why would I
think of looking in the Copying and Pasting topic? That's like saying I
should have guessed that that NSPasteboard was split into two pieces. If I
already knew the answer to my problem, I'd already know the answer to my
problem - that goes without saying. But I don't. If the information I
needed is given under Copying and Pasting then duplicate, or at least refer
to, that same information from within the NSPasteboard page.
Hope this makes it clear. This sort of thrashing around is very typical.
Your query shows exactly what the problem is - not a problem with you
personally, I mean, but it shows how the documentation fails to put itself
in the user's place. The documentation is very nice, as your own query
shows, if you already happen to know the answer and just need to be
reminded; but it is not written for someone who does NOT know. But that is
just the person for whom it should be written. Information needs to be
located, or be linked to, at the place where the user will be when he's
looking for it - not some other place that he might find if he happens to
have memorized all the names of all the topics and classes and thinks to
try opening some other document.
By the way, I'm a teacher, an author, an indexer, and a documentation
writer, with a reputation for anticipating the reader's thought processes
and putting stuff where he needs it - and available for hire. :-) m.
--
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt
pantes gar anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.