• 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: Custom objects in drag pasteboard? Still need help!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom objects in drag pasteboard? Still need help!


  • Subject: Re: Custom objects in drag pasteboard? Still need help!
  • From: Michael Carter <email@hidden>
  • Date: Thu, 2 Jun 2005 19:35:41 -0700

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:

some stuff. see earlier posts.


#mikec
 _______________________________________________
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

  • Follow-Ups:
    • Re: Custom objects in drag pasteboard? [solved]
      • From: Michael Carter <email@hidden>
  • Prev by Date: Re: NSLayoutManager looping with custom NSTextContainer
  • Next by Date: Re: Manual KVO and will/didChangeValueForKey
  • Previous by thread: Re: completePathIntoString doesn't work with unicode paths??
  • Next by thread: Re: Custom objects in drag pasteboard? [solved]
  • Index(es):
    • Date
    • Thread