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

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


  • Prev by Date: Re: Mutability
  • Next by Date: Clear a NSTextView?
  • Previous by thread: Re: Framework distribution, aka Multilevel Frameworks
  • Next by thread: Re: NSCoder and archiving
  • Index(es):
    • Date
    • Thread