Re: Drag and drop between two table views.
Re: Drag and drop between two table views.
- Subject: Re: Drag and drop between two table views.
- From: Paul Johnson <email@hidden>
- Date: Wed, 27 Oct 2010 16:45:48 -0500
I think I've made some progress. I've rewritten
tableView:writeRowsWithIndexes:toPasteboard: for the source table view:
- (BOOL) tableView:(NSTableView *)tv
writeRowsWithIndexes:(NSIndexSet *)rowIndexes
toPasteboard:(NSPasteboard *)pboard {
NSArray *rows = [self arrangedObjects];
NSMutableArray *selectedItems = [NSMutableArray arrayWithCapacity:[rowIndexes
count]];
NSInteger index = [rowIndexes firstIndex];
while (index != NSNotFound) {
[selectedItems addObject:[rows objectAtIndex:index]];
index = [rowIndexes indexGreaterThanIndex:index];
}
[pboard declareTypes:[NSArray arrayWithObject:BFDragPasteboardType] owner:
nil];
[pboard setPropertyList:selectedItems forType:BFDragPasteboardType];
return YES;
}
The array that I write to the pasteboard is of type NSCFArray and contains
the selected rows. I'm using Core Data and so the written data looks like
this:
*(gdb) **po selectedItems*
<NSCFArray 0x1024555e0>(
<Market: 0x1148f3170> (entity: Market; id: 0x1142085d0
<x-coredata://4D7B887D-F13E-4D17-9D1D-BBFD9D36A00D/Market/p321> ; data: {
exchange = NASDAQ;
name = "Apple Inc.";
symbol = AAPL;
})
)
Where I'm still having problems is in the array controller for the second
table. What I have so far doesn't work:
- (BOOL)tableView:(NSTableView *)aTableView
acceptDrop:(id <NSDraggingInfo>)info
row:(NSInteger)row
dropOperation:(NSTableViewDropOperation)operation {
id current;
NSPasteboard *pb = [info draggingPasteboard];
NSEnumerator *enumerator;
enumerator = [[pb propertyListForType:@"selectedItems"] objectEnumerator];
while ( (current = [enumerator nextObject]) ) {
NSLog(@"%@", current);
}
return YES;
}
Obviously I don't have a good understanding of how to read the pasteboard,
so I'm looking for some help on this one. Graham Cox's reply to my original
query allowed me to make progress, but I'm still unable to complete what
should be a trivial exercise.
_______________________________________________
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