• 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: how do I save my NSOutlineView items into a file?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how do I save my NSOutlineView items into a file?


  • Subject: Re: how do I save my NSOutlineView items into a file?
  • From: email@hidden
  • Date: Thu, 23 Feb 2006 10:14:31 -0800

2006/02/22, at 23:37, オウ ショビン wrote:

I have written the following codes to save my NSOutlineView items. But when I debug the codes, it seems only the parentNode is saved but not including those children. I don't know why? I want to know whether "NSArchier" can used to save outlineView or not, though I found it can used to save the items of TableView.
And In general, how to save outlineView items.


Thanks for any help.
lepton
---------------------------------------------------------------------- ----------------------------
- (IBAction)saveData:(id)sender
{
NSSavePanel *savePanel = [NSSavePanel savePanel];

[savePanel setTitle:@"Save NSOutlineView"];
[savePanel beginSheetForDirectory:NSHomeDirectory() file:nil modalForWindow:myWindow modalDelegate:self didEndSelector:@selector(didEndSaveSheet:returnCode:contextInfo:) contextInfo: NULL];
}


-(void) didEndSaveSheet:(NSSavePanel *)savePanel returnCode:(int) returnCode contextInfo:(void *)contextInfo
{


	if(returnCode == NSOKButton) {
	NSString *filename = [savePanel filename];
	[NSArchiver archiveRootObject:myOutlineItems toFile:filename];
NSKeyedArchiver is the preferred way to save archives. NSArchiver is depreciated.

//"myOutlineItems is NSMutableArray that includes all items in myOutlineView that is ture. 
Here for example: myOutlineView only include one column "


	[myOutlineView setAutosaveExpandedItems:YES];
	}
}
Are all of your objects for your outline view compliant for NSCoding? I see encodeWithCoder here, but what about implementing initWithCoder ?
Also, you need to call super in those two methods.


-(void)encodeWithCoder:(NSCoder *)encoder
{
	[encoder encodeObject:itemName];
}
Here, are each itemName object compliant for NSCoding? You should use encodeObject: forKey: in combination with NSKeyedArchiver.
You also need to call [super encodeWithCoder:coder]; before anything else in your object.


Have you read: http://developer.apple.com/documentation/Cocoa/ Conceptual/Archiving/index.html ?

Andre
email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: how do I save my NSOutlineView items into a file?
      • From: xbwang <email@hidden>
References: 
 >how do I save my NSOutlineView items into a file? (From: オウ ショビン <email@hidden>)

  • Prev by Date: Re: Simple string replacement
  • Next by Date: Working with modem
  • Previous by thread: how do I save my NSOutlineView items into a file?
  • Next by thread: Re: how do I save my NSOutlineView items into a file?
  • Index(es):
    • Date
    • Thread