Re: Data source management in NSOutlineView
Re: Data source management in NSOutlineView
- Subject: Re: Data source management in NSOutlineView
- From: "Mark A. Stratman" <email@hidden>
- Date: Fri, 25 Jun 2004 02:16:11 -0500
I've only looked at the DragNDropOutlineView sample long enough to
steal its ImageAndTextCell class. ;-)
So I can't address how it does (if it does) save and restore data.
What I can say though, is that to save arbitrary objects (like its
TreeNode and SimpleTreeNode I'd assume?), their classes can implement
NSCoder methods.
(
http://developer.apple.com/documentation/Cocoa/Conceptual/Archiving/
Tasks/codingobjects.html) The root object can then be turned into
NSData suitable for saving with NSKeyedArchiver methods, and unarchived
with NSKeyedUnarchiver.
If it's any help, you can take a look at a fairly simple project that
archives and unarchives its NSOutlineView data here:
http://yafca.sourceforge.net/
I basically just have an NSArray as the "root" object since there is no
single root object in the outline view. The array contains custom
"deck" objects, each of which has an array of its own (among other
things) with more decks or "card" objects.
All that was required to save and restore this data was to implement
NSCoder methods in FCDeck.m and FCCard.m, then elsewhere (in
AppController.m in my case) wherever is appropriate, use
NSKeyedArchiver/NSKeyedUnarchiver methods to archive/unarchive the root
object (an NSMutableArray in my case).
- mark
On Jun 24, 2004, at 11:53 AM, Jeremy Dronfield wrote:
I'm trying to get to grips with the DragNDropOutlineView example
provided by Apple. Having struggled past some of its pointlessly
obfuscatory features ("random" icon images, the strange mud-and-straw
handmade dictionary file), I've come up against a major obstacle:
there's no illustration of how to turn the tree node data back into a
dictionary so that it can be saved.
If anyone knows how to do this, could they please explain it to me, or
point me in the right direction?
Regards,
-Jeremy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.