• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Data source management in NSOutlineView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Data source management in NSOutlineView


  • Subject: Re: Data source management in NSOutlineView
  • From: Jeremy Dronfield <email@hidden>
  • Date: Fri, 25 Jun 2004 09:57:36 +0100

On 25 Jun 2004, at 8:16 am, Mark A. Stratman wrote:

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.

It builds its tree from a strange hand-made dictionary file, and provides a covenience method for handling this conversion. So, provided you hand it a dictionary structured in the same way, giving it data is no problem. However, there's no convenience method for turning the tree back into a dictionary.

Since posting, I've looked again at the TreeNode class, and I think I can see a way to use its instance methods to parse it and build my own convenience method. Haven't tried yet, though...

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).

I may end up using archiving if my convenience method proves a non-starter. Thanks for the pointers.

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.


  • Follow-Ups:
    • Saving DragNDropOutlineView data - SOLVED (was: Data source management in NSOutlineView)
      • From: Jeremy Dronfield <email@hidden>
References: 
 >Data source management in NSOutlineView (From: Jeremy Dronfield <email@hidden>)
 >Re: Data source management in NSOutlineView (From: "Mark A. Stratman" <email@hidden>)

  • Prev by Date: Re: How to tell what API is used
  • Next by Date: Re: Sharing objects between threads
  • Previous by thread: Re: Data source management in NSOutlineView
  • Next by thread: Saving DragNDropOutlineView data - SOLVED (was: Data source management in NSOutlineView)
  • Index(es):
    • Date
    • Thread