NSCoder and archiving
NSCoder and archiving
- Subject: NSCoder and archiving
- From: Ivan Myrvold <email@hidden>
- Date: Fri, 23 Nov 2001 19:03:14 +0300
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];
}
- (id)initWithCoder:(NSCoder *)coder; {
[self setName:[coder decodeObject]];
[self setParent:[coder decodeObject]];
[self setOppskriftArray:[coder decodeObject]];
[self setChildren:[coder decodeObject]];
return self;
}
It looks like the data is stored, but when I debug initWithCoder, the
two last items always returns nil. What do I do wrong here?
Ivan