Re: Question about Archives and Serialisations Programming Guide
Re: Question about Archives and Serialisations Programming Guide
- Subject: Re: Question about Archives and Serialisations Programming Guide
- From: Dave <email@hidden>
- Date: Fri, 05 Feb 2016 17:00:16 +0000
Hi Alex,
Found it! Well, Jean-Daniel did - Thanks again!
I was barking up the wrong tree thinking it was the back links that were the problem. Using weak caused them to (correctly as it turned out) be set to nil when the node it reference is released. The problem was in the initWithCoder method, I was using:
self.pNetworkNodeChildArray = [[NSMutableArray alloc] initWithArray:myArray copyItems:YES];
and that should be - copyItems:NO
I’m not sure where I got the YES from, I think it was from a very simple example I found online. Anyway if you set it to NO, it works as expected.
Worth checking if you have this too when you shouldn’t.
AFAIK, there are no working examples of using a back link like this, if anyone wants to post my sample code to their web-site they are welcome to it, just drop me a line.
All the Best
Dave
> On 5 Feb 2016, at 16:37, Alex Zavatone <email@hidden> wrote:
>
>
> On Feb 5, 2016, at 8:46 AM, Dave wrote:
>
>>
>>> On 5 Feb 2016, at 13:34, Jean-Daniel Dupas <email@hidden> wrote:
>>>
>>> And obviously, you also add - encodeWithCoder: and -initWithCoder: methods in your custom classes.
>>
>> Yes, see my other thread, it decodes all the other fields but not the (weak) back links get set to nil most of the time…….
>
> Ahhhhhhh.
>
> It would seem that the reference is being lost when the archiving happens.
>
> Would something that is the opposite of strongify/weakify work here? Sort of a strongify a weak reference when it comes to archiving and archive the strong reference?
>
> That almost sounds crazy enough to work.
>
>> _______________________________________________
>>
>> 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
>
_______________________________________________
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