Re: NSCoder and archiving
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