• 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: NSCoder and archiving
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSCoder and archiving


  • Subject: Re: NSCoder and archiving
  • From: Ivan Myrvold <email@hidden>
  • Date: Sat, 24 Nov 2001 14:27:57 +0300

Today I stepped through all my encoding step in the debugger, and I have verified that all my objects and all it's fields are in fact populated correctly. But I traced my problems down to a missing "retain" message, which caused my program to crash when I loaded the data.

Thanks anyway!

Ivan

On fredag, november 23, 2001, at 06:47 , John Hvrnkvist wrote:


On Friday, November 23, 2001, at 05:03 , Ivan Myrvold wrote:

I have a class called "KapittelItem", where I try to archive the objects it contains.
I have problems with it, and I think that is because "KapittelItem" contains an NSMutableArray called "children" which contains "KapittelItem" items which I also tries to archive.

Here are my two methods to store and retrieve the data:

- (void)encodeWithCoder:(NSCoder *)coder {
[coder encodeObject:[self name]];
[coder encodeObject:[self parent]];
[coder encodeObject:[self oppskriftArray]];
if (children != IsALeafNode)
[coder encodeObject:[self children]];
else
[coder encodeObject:nil];
}

Does it look OK when you write it out?

- (void)encodeWithCoder:(NSCoder *)coder {
[coder encodeObject:[self name]];
[coder encodeObject:[self parent]];
NSLog(@"Headers: %@",[self oppskriftArray]);
[coder encodeObject:[self oppskriftArray]];
if (children != IsALeafNode)
{
[coder encodeObject:[self children]];
NSLog(@"Write subsections:%@",[self children]);
}
else
{
[coder encodeObject:[self children]];
NSLog(@"No subsections");
}
}

Why the test on IsALeafNode, by the way?

Regards,
John Hvrnkvist

--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com


  • Prev by Date: Re: Instance methods VS. Class methods
  • Next by Date: Setting an Outlet to an NSTextView in IB, it seems to get the NSScrollView instead.
  • Previous by thread: NSCoder and archiving
  • Next by thread: Clear a NSTextView?
  • Index(es):
    • Date
    • Thread