I'm implementing drag and drop for a NSCollectionView. The idea is to rearrange objects in the collection by dragging them to another location. Having read the docs for NSCollectionViewDelegate and NSPasteboard, I still have a few general questions about the concept.
The objects themselves conform to both the NSPasteboardWriting and NSPasteboardReading protocols. In the collection view delegate, I have implemented the protocol methods that allow me to initiate a dragging session, and to write the dragged items to the pasteboard. I'm writing the objects as NSData objects, using NSKeyedArchiver. I have also implemented the methods to validate and accept the drag operation. In the latter, I am reading the dragged items back from the pasteboard, using readObjectsForClasses:[NSArray arrayWithObject:[MyObject class]] It seems that the objects read from the pasteboard are not the same as the original dragged objects; they only represent the same data. This seems natural to me, as I'm using a archiver in the process, but I'm really not sure if I should somehow find a way to retrieve the original objects from the pasteboard. Is this at all possible?. If I should indeed proceed with these different objects that have been read from the pasteboard, I'm wondering how to effectively perform the move in my model array: should I just insert the objects into my array model object at the desired location and remove the original ones, or should I try to find a way to reference the original objects (using an identifier in the items obtained from the pasteboard) and move those around in my model array? If the latter; what kind of identifier could be used for this? Some kind of ivar with a unique value? How to generate something like this? Thanks for any advice on this -- Luc Van Bogaert _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com