Re: Archiving objects without their owner[1]
Re: Archiving objects without their owner[1]
- Subject: Re: Archiving objects without their owner[1]
- From: Dan Bernstein <email@hidden>
- Date: Wed, 19 Dec 2001 08:59:04 +0200
On Wednesday, December 19, 2001, at 06:30 AM, Andre Lipinski wrote:
If you'd like to just handle one owner per archive, it's real easy, use
replaceObject:[NSNull null] withObject: then decode the root object.
With multiple replaced things it's more tricky if you'd like some tips,
please email.
Andre.
Thanks.
However, it doesn't seem to work for me. Here's what I did for archiving:
NSArchiver *myArchiver = [[[NSArchiver alloc]
initForWritingWithMutable
Data:[NSMutableData data]] autorelease];
[myArchiver replaceObject:self withObject:[NSNull null]];
[myArchiver encodeRootObject:theRootObject];
I then store [myArchiver archiverData]. Here's how I unarchive:
NSUnarchiver *myUnarchiver = [[[NSUnarchiver alloc]
initForReadingWith
Data:theData] autorelease];
[myUnarchiver replaceObject:[NSNull null] withObject:self];
theRootObject = [myUnarchiver decodeObject];
Yet the unarchived object contains pointers to <null> instead of to the
object doing the unarchiving.
What's wrong?
-- Dan