CoreData + NSOutlineView + Drag and Drop
CoreData + NSOutlineView + Drag and Drop
- Subject: CoreData + NSOutlineView + Drag and Drop
- From: Douglas Anarino <email@hidden>
- Date: Mon, 6 Jun 2005 01:47:23 -0400
Hi,
I've built a simple CoreData application with an NSTableView that
displays a hierarchy of topics, subtopics and 'lessons'. Being new to
Cocoa as well as CoreData, I am BLOWN AWAY by how easy it was to
create the data model, bind the interface together and save the data.
I was hoping there might be some magic button that would enable the
managed objects to be easily repositioned with drag and drop, but
have so far been unable to find it :(
What I have found is a few different approaches to dragging and
dropping in tables and outlines, but none of them seem to be using
CoreData. So far, the closest example to what I'm attempting is the
document based Bookmarks application here:
http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
It seems to be populating a subclassed table view with a subclassed
array controller. I've been trying to replicate the example with a
subclassed outline and tree controller (using the corresponding
'item' based methods). I guess I'm having trouble with the bindings
for the tree controller. I get a message in the run log 'Illegal
NSOutlineView data source' complaining that the tree controller needs
to implement methods in the NSOutlineViewDataSource protocol.
In the original example, the table view has its contentArray bound to
an array in the document object (in addition to having the column
values bound to the array controller's selection). I'm guessing that
the corresponding settings in my scenario should somehow be binding
the outline's content (array? object? set?) to my app delegate's
managedObjectContext, but I'm not sure how.
Or do I need to bind directly to the app delegate somehow, and have
it implement the tree data source protocol by creating fetchRequests
for the managedObjectContext? If so, what would the outline's
bindings/connections look like? I'm running on the premise that I
need to set the outline's dataSource in order to get it to send
outlineView: writeItems: toPasteboard: somewhere, but is this still
the way now that CoreData's around? It seems like the
managedObjectContext has all the relationship information it needs to
handle drag and drop of its managedObjects.
This thread from last month...
Core Data + Drag and Drop
http://www.cocoabuilder.com/archive/message/cocoa/2005/5/10/135449
... seems to suggest that what I'm trying to do is possible, and I
can even see how this tidbit (putting the managedObject's URL on the
pasteboard) might fit in later, but I guess I'm confused about what
all needs to be implemented and subclassed to get to this point. Any
pointers in the right direction would be much appreciated.
TIA,
doug
http://syntropo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden