Re: Encoding infinite loops
Re: Encoding infinite loops
- Subject: Re: Encoding infinite loops
- From: Uli Kusterer <email@hidden>
- Date: Tue, 22 May 2007 10:10:12 +0200
On 21.05.2007, at 18:47, Chris Kane wrote:
Consider for a moment an object unarchiving itself. The unarchiver
has created the object for that reference in the archive and is
initializing it. The object unarchives a bunch of other state,
some of which is more objects. If one of the subobjects has a
reference to the original object, and unarchives that, the
unarchiver happily gives it the object which it has already created
for that object -- but in this case note that that object is still
initializing itself. This can create two sorts of problems, but in
the lucky case everything unwinds and things work out and the
recursive reference has been restored by the unarchiver.
Err... you mean this class is documented as handling several
references to the same object ... but doesn't?
Can't you just keep a original pointer -> object dictionary (which
contains the object that actually was unarchived, not any temporary
object that might have been replaced) and just look up each object in
the graph that way? This is a problem that's been solved so many
times over that I'm kind of embarrassed that a framework like Cocoa
doesn't handle this, and moreover is unable to fail gracefully in
that case instead of unarchiving garbage objects.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden