Re: crashes loading saved file
Re: crashes loading saved file
- Subject: Re: crashes loading saved file
- From: James Maxwell <email@hidden>
- Date: Tue, 29 May 2012 00:32:17 -0700
>
> That sounds like it could be a big clue, to me.
>
> encodeConditionalObject only encodes the object reference if it has been seen by the archiver already. If it hasn't, nil is encoded. So if things are breaking when you use it, it means that parts of the object graph you think you encoded were not.
>
> It's pretty useful for archiving backpointers (though I agree that recreating these rather than archiving them is probably safer).
>
> Assuming that your graph has a root node, archiving from root to leaves should be OK, but you should use encodeConditionalObject for any object you think you should have already archived (like parent nodes).
>
> Another issue could be that if you are storing your parent and child nodes in an array, you probably have pretty solid retain cycles all over the place. Backpointers should almost always be weak (nonretained) references, which calls for special treatment if you want to put them in an array (use [NSPointerArray pointerArrayWithWeakObjects]).
Thanks, Graham. This is a good thought. I've not heard of NSPointerArray beforeā¦ I'll look into it. It sounds like exactly the kind of structure I should be using.
J.
_______________________________________________
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