Re: Archive/Unarchive Problem - Bug in MacOSX/Cocoa?
Re: Archive/Unarchive Problem - Bug in MacOSX/Cocoa?
- Subject: Re: Archive/Unarchive Problem - Bug in MacOSX/Cocoa?
- From: Dave <email@hidden>
- Date: Fri, 05 Feb 2016 18:15:10 +0000
> On 5 Feb 2016, at 16:10, Keary Suska <email@hidden> wrote:
>
>
>> On Feb 5, 2016, at 8:45 AM, Dave <email@hidden> wrote:
>>
>> Hi All,
>>
>> I have written a Test App that demonstrates the problem, please let me know if you’d like a copy.
>>
>> I’m not sure if its a bug or not and if not a bug then how to make it work. Everyone keeps telling me its possible but no one seems to know how to make it work.
>>
>> According to the (few) docs I found on it, its possible too, but again it doesn’t actually tell you how to do it.
>>
>> I’ll use up a DTS incident on this but they will take forever to respond and I jwish I knew for certain whether this is *SUPPOSED* to work or not. It doesn’t actually say in black and white one way or the other.
>
> I would like to see a copy, as I am curious why it isn’t working. The issue isn’t that no-one knows how, it is that it is simply supposed to work. There shouldn’t be anything you need to do to encode a complex graph.
>
> However, I can see that *decoding* the graph could be difficult. The decoding of any single object happens in the -initWithCoder: implementation of that object. One would think that until that method is exited, NSCoder cannot know that the object exists. Therefore If any of its child objects reference it, how can the coder know which object to use? I don’t know how, or if, NSKeyedUnarchiver handles this situation.
It works now. It handles it by doing at least two passes. The first pass it creates a dictionary of all “Unique” Objects, and then on the second pass substitutes references to keys in the dictionary…….
> You may have to handle it yourself—i.e. do not encode “parent” properties and instead set the property value in the parents’ -initWithCoder:.
I knew it would handle it, I just thought there was some magic you had to somehow provide, but this “magic” is provided by the Archiver/Unarchiver *if* you don’t inadvertently break the self-referential nature of the original network.
All the Best
Dave
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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