views:

92

answers:

2

I read the other post here on Outlineviews and DND, but I can't get my program to work. At the bottom of this post is a link to a zip of my project. Its very basic with only an outlineview and button. I want it to receive text files being dropped on it, but something is wrong with my code or connections. I tried following Apple's example code of their NSOutline Drag and Drop, but I'm missing something. 1 difference is my program is a document based program and their example isn't. I set the File's Owner to receive delegate actions, since that's where my code to handle drag and drop is, as well as a button action. Its probably a simple mistake, so could someone please look at it and tell me what I'm doing wrong? Here is a link to the file: http://dl.dropbox.com/u/7195844/OutlineDragDrop.zip

A: 

Ok, here is a dropbox link: http://dl.dropbox.com/u/7195844/OutlineDragDrop.zip

bob
You should edit things like this into your question, not post them as answers.
Peter Hosey
+2  A: 

You implemented the table view data source drag-reception methods, not the outline view data source drag-reception methods. An outline view is a kind of table view, but it uses the outline view data source protocol exclusively; the table view data source protocol is only for table view data sources, not outline view data sources.

See the NSOutlineViewDataSource protocol for more details on exactly what you need to implement in your data source.

On that note: You need to implement the methods in your data source, which is currently not your document. I don't know why you've done it that way; ordinarily, the document (in its role as mostly a controller) owns the model, so it should be the views' source of the data—the data source.

I suggest merging the OutlineDataSource class into the MyDocument class, and changing the table view drag-reception methods to their outline-view counterparts.

Peter Hosey