Re: Newbie: Drag of Custom Type from NSOutlineView
Re: Newbie: Drag of Custom Type from NSOutlineView
- Subject: Re: Newbie: Drag of Custom Type from NSOutlineView
- From: Jerry Krinock <email@hidden>
- Date: Thu, 01 Dec 2005 06:58:47 -0800
- Thread-topic: Newbie: Drag of Custom Type from NSOutlineView
on 05/11/19 16:32, Jerry Krinock at email@hidden wrote:
>
- (BOOL)outlineView:(NSOutlineView*)olv
>
writeItems:(NSArray*)items
>
toPasteboard:(NSPasteboard*)pboard
>
{
>
NSArray* myTypeOnly = [NSArray arrayWithObject:MyPboardType];
>
[pboard declareTypes:myTypeOnly owner:self];
>
>
NSLog(@"Writing items to %@ pasteboard:\n%@", pboard, items) ;
>
>
BOOL success = [pboard setPropertyList:items
>
forType:MyPboardType] ;
>
>
NSLog(@"success writing to pasteboard = %i", success) ;
>
NSLog(@"pboard payload looks like:\n%@",
>
[pboard propertyListForType:MyPboardType]) ;
>
>
return success ;
>
}
>
>
The first NSLog logs an array containing the dragged items, as expected.
>
The second NSLog logs that success = 1, as expected.
>
The third NSLog simulates what my drop destination does to unload the
>
pasteboard. I expect to get my array of items, but I get (null). The same
>
thing happens in the actual drop method.
>
>
How can something so simple not work?
I found the answer to this. Some of the objects in the items array are
dictionaries, and some of these dictionaries contain NSValues. NSValues
cannot be put in property lists, (apparently) even if they are wrapped in
dictionaries (which is an interesting topic but not for this thread).
The NSPasteboard setPropertyList:forType: documentation says:
"Returns YES if the data is successfully written or NO if ownership of the
pasteboard has changed. Any other error raises an
NSPasteboardCommunicationException."
In fact, under these circumstances the method does not successfully write
data, but returns YES and does NOT raise any exception (at least nothing
shows up in console.log). I suppose that one of Apple's lawyers might be
able to argue that it is OK to return YES here, but the lack of an exception
would be tough to explain, and certainly the above documentation is
ambiguous as Hell (for those of you who believe that Hell is ambiguous).
So, I filed a bug report with Apple.
Jerry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden