开发者

NSOutlineView with Drag and Drop

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜