• 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
Drag and drop in collectionview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Drag and drop in collectionview


  • Subject: Drag and drop in collectionview
  • From: Luc Van Bogaert <email@hidden>
  • Date: Sat, 28 Jan 2012 13:35:03 +0100

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 (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


  • Follow-Ups:
    • Re: Drag and drop in collectionview
      • From: Luc Van Bogaert <email@hidden>
  • Prev by Date: Re: Open a new terminal tab or window from a Cocoa app at a certain directory without using NSAppleScript?
  • Next by Date: Re: Blocks and Methods...
  • Previous by thread: Re: Trying to customize UITableViewCell with IB but having odd exception
  • Next by thread: Re: Drag and drop in collectionview
  • Index(es):
    • Date
    • Thread