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: Alex Zavatone <email@hidden>
- Date: Fri, 05 Feb 2016 13:36:32 -0500
Sure. That would be nice.
I also recall some classes for archiving and dearchiving that use introspection that automatically handle the proper action in one line of code.
For simple cases with straightforward collection classes, this is a really really really nice approach and frees us from having to write special case code for each property.
Something like automaticInitWithCoder and automaticEncodeWithCoder.
It would be nice if the default operations were able to use Objective-C's introspection to achieve this, but well, they don't.
If anyone knows of these more automatic initers and encoders, I'd sure like a pointer to them.
Thanks and happy you got it working, Dave.
Alex Zavatone
On Feb 5, 2016, at 12:00 PM, Dave wrote:
> 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
_______________________________________________
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