tags:

views:

65

answers:

1

I have an NSCollectionView that is properly configured to display Core Data Entities based on what's found in an NSArrayController. These Core Data entities, named MyManagedType, are defined to include an int32 indexing number "indexNumber" to keep them ordered, and binary NSData *myData. I can also select the items by clicking them, but I can't "click and drag" them. I only need to be able to select 1 item at a time (preferable actually).

I populate the NSArrayController by dragging and dropping files from finder in to the NSCollectionView. It accepts dropped files by getting their FILENAMES. I then open the file, do my processing, populate myData, get a new indexNumber (indexNumber = # of MyManagedType entities in persistent store), and insert this NSManagedObject * in to my persistent store. That works great.

The 2 things I want to add, I'm lost.

1) I want to be able to click and grab an item in the NSCollectionView, drag it outside the view (or window), and drop it to "poof" it and have it delete from my persistent store.

2) I want to be able to click and grab an item in the NSCollectionView, drag it to ANOTHER SPOT in my NSCollectionView, and drop it to reorder my indexNumbers.

The main stumbling point here is I don't understand what drag&drop types to set myself up to handle - with my existing code it is filenames, but what is it now? I've read the class reference several times and I understand what a lot of the methods do, but I just can't wrap my head around how I achieve #1 and #2.

A: 

I wanted to get drag and drop working on an NSOutlineView, and I found Jonathan Dann's source code incredibly helpful.

You might want to check it out and try to modify it for use with NSCollectionView.

John Gallagher