• 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: Saving NSTableView data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving NSTableView data


  • Subject: Re: Saving NSTableView data
  • From: Brent Gulanowski <email@hidden>
  • Date: Fri, 28 Jun 2002 01:55:56 -0400

On Thursday, June 27, 2002, at 03:00 PM, Aidas wrote:

Hi all,

I have a NSTableView. It has multiple collumns. How could I save it's data
into file and later read it?

Thank you

How did you get that data into the NSTableView in the first place? You will find part of your answers there. But here's the party line, as I interpret it.

Recode your concept of the NSTableView. It is not a storage class, it is a display (aka view) class. It is not designed to have persistent data "inside" it (and its awkward to attempt this). Instead you use it to present an interpretation of that data (properly stored elsewhere). The *data source* is an object from which your table view requests representative information to display. The data source object may contain your real (model) data, or it may (as others on this list recommend) request the appropriate data from the model object(s) and repackage them for presentation.

Identify where your data originally came from. In order to save your persistent data to, and load it from, a file, you use the NSArchiver and NSUnarchiver classes (or perhaps your *own* subclasses of NSCoder and NSDecoder). They convert your objects and their instance data to and from a form suitable for raw storage. However, this requires you to adopt the NSCoding protocol in all of your custom objects. Furthermore, your adopting objects must be managed by an NSDocument subclass, which will handle the actual conversion using the saving and loading methods described in the documentation.

See chapter 6 of Cocoa Programming for OS X (Addison Wesley),
or chapter 13 of Building Cocoa Applications (O'Reilly)
or Vermont Recipes, Recipe 1 step 4: (http://www.stepwise.com/Articles/VermontRecipes/index.html)

It's a bit much to write it up in an email, and these are excellent sources. Give yourself an hour or two to read the information and put together and test the sample code, and you'll have a very good understanding of it when you're done.

Brent
_______________________________________________
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.

References: 
 >Saving NSTableView data (From: Aidas <email@hidden>)

  • Prev by Date: Re: Saving NSTableView data
  • Next by Date: Re: What's STILL wrong with "symbol" fonts?
  • Previous by thread: Re: Saving NSTableView data
  • Next by thread: Communication between classes
  • Index(es):
    • Date
    • Thread