Re: Archive/Unarchive Problem/Question?
Re: Archive/Unarchive Problem/Question?
- Subject: Re: Archive/Unarchive Problem/Question?
- From: Dave <email@hidden>
- Date: Thu, 04 Feb 2016 19:29:45 +0000
Hi Jens,
> On 4 Feb 2016, at 19:21, Jens Alfke <email@hidden> wrote:
>
>
>> On Feb 4, 2016, at 11:02 AM, Dave <email@hidden <mailto:email@hidden>> wrote:
>>
>> However, after I unarchive this object, the pNetworkParentNode property is nil.
>
> Is this after the entire object graph has been unarchived, or is it inside your -initWithCoder: method?
After the entire Network has been unarchived. All three of the top level properties should be setup:
NSMutableArray* pNetworkArray; //Contains an Hierarchical Array of LTWNetworkNode’s
NSMutableDictionary* pNetworkDict //Contains a Hierarchical Dict of LTWNetworkNode’s
NSMutableDictionary* pNetworkFlatDict /Contains Flat Dictionary of Key-LongID/LTWNetworkNode’s
And in pNetworkArray the Children seem fine, but the parents are all nil. Can’t think how to debug this especially as I can’t look at it in the debugger. I was wondering if this is in fact a clue somehow?
>
>> I was wondering about copyWithZone, should I use copy for this?
>
> No! That would make each node’s parent point to a copy of the parent, not the real parent, which would probably be disastrous.
Yes, and because it’s the same class it causes an infinite loop too!
>> Meant to Add that pNetworkParentNode is defined as weak - does this make a difference? If I make it strong, it would cause a cycle?
>
> Hm. I don’t know how weak ivars interact with unarchiving. They should work OK, since the unarchiver has a collection that points to every object that’s been unarchived and will keep any of them from getting dealloced, but I”m not sure.
>
> But yeah, if you make that strong you’ll have cycles.
Yes, how about assign? Makes me a bit nervous because if they go stale, they don’t get set to nil?
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