• 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: Bindings, TableViews, and saving...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings, TableViews, and saving...


  • Subject: Re: Bindings, TableViews, and saving...
  • From: mmalcolm crawford <email@hidden>
  • Date: Mon, 26 Jul 2004 21:25:04 -0700

On Jul 26, 2004, at 7:56 PM, James McConnell wrote:

I'm working on a fairly common project where I have a table view
using an NSArrayController to handle custom model objects. I can hook up
all the bindings correctly like in the tutorials, but what I'd like to be
able to do is to take the information from the TableView and save it to disk
as a custom file type. How would I go about this?

The same as you would a non-bindings application: make your custom objects archivable and archive the array (or in the general case, the root object)...


For example, starting with the Shopping List example at
<http://homepage.mac.com/mmalc/CocoaExamples/controllers.html>

you might implement suitable get/set accessors for itemsArray then something conceptually similar to:

- (IBAction)save:sender
{
NSString *path =
[@"~/Library/Application Support/MyApp/MyAppsData" stringByStandardizingPath];
[itemsArray writeToFile:path atomically:YES];

}


- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
NSString *path =
[@"~/Library/Application Support/MyApp/MyAppsData" stringByStandardizingPath];
NSArray *array = [[NSArray alloc] initWithContentsOfFile:path];
[self setItemsArray:array];
[array release];
}


mmalc
_______________________________________________
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: 
 >Bindings, TableViews, and saving... (From: James McConnell <email@hidden>)

  • Prev by Date: Re: screen capture, using SoftVDigX
  • Next by Date: E-Mail Client Code Suggestions
  • Previous by thread: Bindings, TableViews, and saving...
  • Next by thread: Re: Bindings, TableViews, and saving...
  • Index(es):
    • Date
    • Thread