I've tried just about everything to get to this array later, but nothing works!
I'm almost convinced that it can't be done (but I know better).
All I need to do is copy selected objects from one tableview onto a row in another tableview via drag (in a non-doc app). Here's what I'm trying:
1) When drag starts, create an array with the selected row objects.
2) write them to the drag pasteboard with type CopiedRowsType (defined as an NSString with value: COPIED_ROW_TYPE).
3) in tableView:acceptDrop:row:dropOperation:, fetch the CopiedRowsType array from the pasteboard.
4) add the items in the array to the object they were dropped onto.
In tableView:writeRows:toPasteboard, the objects are being added to an NSMutableArray just fine. Right before I return I assign the array to the pasteboard using setPropertyList:forType:. I log a quick count of objects in the array and verify that they are there.
When the drag ends in tableView:acceptDrop:row:dropOperation I fetch the CopiedRowsType item off the pasteboard and immediately count the rows. It always comes back zero.
- (BOOL)tableView:(NSTableView *)tv
acceptDrop:(id <NSDraggingInfo>)info
row:(int)row
dropOperation:(NSTableViewDropOperation)op
{
...
NSLog( @"Drop onto routesView received. Dropping into row %d", row );
NSArray *copiedRows = [[info draggingPasteboard] propertyListForType:CopiedRowsType];
NSLog( @"Fetching CopiedRowsType from dragging pasteboard. %d items.", [copiedRows count] );
The only time copiedRows has data is when I create an array of string literals. The strange thing is that I add 2 other types to the pasteboard along with CopiedRowsType. One is the row parameter passed into tableView:writeRows:toPasteboard:, and the other is an NSString I use for drags to other apps. Both those work fine and remain in the drag pasteboard.
Is there some other method I should be using to handle this? It seems that tableView:writeRows:toPasteboard is storing the array, but maybe not. I can't tell! Using if( [pboard setPropertyList:copiedRows forType:CopiedRowsType] == NO ) never fails, so I have to assume the array is being set. Using Clipboard Viewer I see the entry after the drop, but it contains 0 bytes.
Do I have to archive the array and use setData:forType:? Is there something else I'm missing?
On Jun 1, 2005, at 9:56 PM, Michael Carter wrote: