views:

1014

answers:

3

I have found a Tutorial here on how to implement drag and drop in an Outline View. The only problem I have is I don't know where to put the code from the tutorial. I would appreciate it greatly if you could tell me where I should put the code in a Xcode Project to make it work. Thanks!

+2  A: 

You might want to check out this tutorial as well (there is also a part two which details unordered trees).

In particular, the linked tutorial contains an XCode projects that should get you started. Check out DragController.m to see where you put the code you referenced with your link.

Naaff
I've tried using the code in your link by just adding the Drag Controller to my Project but it stops the Core Data From working.
Joshua
If you compile and run the XCode project from the linked tutorial you should see that everything works as advertised with drag and drop. That being the case, it seems that the example should be sufficient to answer all of your questions. I'd suggest you study the tutorial description carefully and follow all of the steps, only using DragController.m as an example. It's unlikely that you can just drop it into your project.
Naaff
I take another look.
Joshua
I took another look and replicated what they did in their Xcode project but it now stops me from adding anything. I think it's something to do with my Core Data Model being different from theirs. Here's mine if you want to take a look. http://snapplr.com/6gkw
Joshua
+2  A: 

They're delegate/data source methods, so you put them into the outline view's delegate and data source. Usually this is your controller object, but it's up to you to hook up the connections in IB or programatically. I'd actually suggest learning how data source and delegate methods work before using bindings or Core Data, since bindings isn't meant to replace knowledge of lower level code (and you're going to run into a lot of problems with bindings until you have a solid understanding of the basics).

Also, keep in mind NSTreeController has improved a bit since 10.5, from what I've heard you should be able to get the real observed object without using private methods anymore.

Marc Charbonneau
Really, is there a tutorial on how to get the real observed object without using private methods?
Joshua
How would I use arrangedObjects to implement Drag and Drop>
Joshua