On 29/05/2012, at 3:08 PM, James Maxwell wrote:

> I did try, btw, using encodeConditionalObject for parentNodes, sourceNodes, 
> and superState, all of which are CbCMNodes. But the structure was no longer 
> intact after trying this (parent connections gone), so I think I 
> misunderstood how conditional objects are supposed to work...


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]).

--Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to