• 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: Michael Gersten <email@hidden>
  • Date: Thu, 11 Jul 2002 19:44:19 -0700

> >> I have a NSTableView. It has multiple collumns. How could I save it's
> >> data
> >> into file and later read it?
> >
> > I'm assuming that what you really want to do is save the data from the
> > NSTableView's data source, which should be an object that implements
> > the NSTableDataSource protocol.

Here's a very different approach to this idea, based on the idea of controllers and a data bus.

Step one: use the NSTableDataSource protocol methods to read the data from your data source.
Step two: Store that data into an array. (each element a dictionary row, or a sub-array).
Step three: Save that array to a file.

To read it later, just refetch the array via plist, and display it again in a new TableView.

All you'd need is a data source controller that can take data from an array of arrays, or an array of dictionaries with a known ordering on the keys. That sounds standard enough to find in one of the third party extras frameworks (Omni, MPW, etc).

> > I'm also assuming that the data source is implemented internally as an
> > NSArray of rows, with each row containing an NSDictionary of named
> > columns. Or perhaps it's vice-versa, and your columns collection is
> > topmost, with each column containing an array of rows.
> >
> > Either way, whether the top-level collection object is an NSArray or an
> > NSDictionary, you can use its writeToFile:atomically: method to store
> > its contents to a file in property list (plist) format, and
> > initWithContentsOfFile: method to recreate it.
> >
> > sherm--
> >
> > Never put off until tomorrow what you can do today. There might be a
> > law against it by that time.
> > _______________________________________________
> > 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.

--
I am a Mac OS X-Cocoa/WOF/EOF developer, and I'm available for hire. Please contact me at michael-job @ stb.nccom.com if interested. Resume at http://resumes.dice.com/keybounce
_______________________________________________
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.

  • Prev by Date: Re: NSTableView philosophy question.. (MVC Pattern) where to putthe dataSource delegate?
  • Next by Date: Re: NSHost and the IP addresses ...
  • Previous by thread: Re: NSTableView philosophy question.. (MVC Pattern) where to putthe dataSource delegate?
  • Next by thread: Re: NSHost and the IP addresses ...
  • Index(es):
    • Date
    • Thread