Archive/Unarchive Problem - Bug in MacOSX/Cocoa?
Archive/Unarchive Problem - Bug in MacOSX/Cocoa?
- Subject: Archive/Unarchive Problem - Bug in MacOSX/Cocoa?
- From: Dave <email@hidden>
- Date: Fri, 05 Feb 2016 13:42:05 +0000
Hi,
I hoped that someone might have had some ideas on why back links are not working when Archiving/Unarchiving objects. I’ve searched for documentation and sample code that shows using a back-link like this but can’t find anything that says categorically that it should work and nothing that says it won’t work, and, according to Jens it *should* work.
So, is this a Bug in Mac OS X/Cocoa?
Before I started doing this, I asked on this list for the best way to save/restore a network like this and was told to use the Apple Keyed Archiver/Unarchiver, well now I’ve done that and it doesn’t work and I have no chance of debugging it because I don’t have the source code. I can’t help thinking I’d have been better off writing my own methods but its too late for that now…...
I’m wondering if the problem is something to do with the way in which I’ve laid the Object out, basically I’ve got an outer “Container" Class called LTWNetwork, I archive an instance of the LTWNetwork Class, LTW Network contains a number of properties, three of which are to do with the hierarchical network of LTWNetworkNode Objects as so:
NSMutableArray* pNetworkArray; //Contains an Hierarchical Array of LTWNetworkNodes
NSMutableDictionary* pNetworkDict //Contains a Hierarchical Dict of LTWNetworkNodes
NSMutableDictionary* pNetworkFlatDict /Contains Flat Dictionary of Key-LongID/LTWNetworkNodes
LTWNetworkNode has linkage (among other) properties:
LTWNetworkNode* pNetworkParentNode //Reference to Parent
NSMutableArray* pNetworkChildArray //References to Children
NSMutableDictionary* pNetworkChildDict //References to Children
The important thing to remember is that a LTWNetworkNode in the above collections is only present *once*, e.g. all three collections refer to the SAME objective-C object.
I changed the pNetworkParentNode back to “weak”.
Inside pNetworkArray and pNetworkDict is just one object that is referenced by both. This is the root object, as a test I made this a separate property inside my LTWNetwork (Root) Class added the necessary code to initWithCode/encodeObject/copyWithZone and tried it again, this time, instead of ALL of the parents being nil, MOST of them are. It looks like the first level of the Hierarchy has the correct parent, but deeper than that, the Parent is nil.
Here is the log:
Self Test Network: Level: 1
Parent Address : 0x198095f50
Parent LongID : NT3312
Parent IndexPath: 000
Child Address: 0x19f449f50
Child Parent: 0x198095f50
Child LongID : NT3312/JY45
Child Address: 0x19f467f50
Child Parent: 0x198095f50
Child LongID : NT3312/JY688
---------
Self Test Network: Level: 2 - Child Array
Parent Address : 0x19f449f50
Parent LongID : NT3312/JY45
Parent IndexPath: 000.000
Child Address: 0x19a076f50
Child Parent: 0x0
Child LongID : NT3312/JY45/TT327
selfTestNetwork - Error Child/Parent Mismatch - Error Count: 1
myLevelNumber: 2
Parent: NT3312/JY45
Child : NT3312/JY45/TT327
—————
Does anyone have any idea how to solve this? I can’t believe its this difficult to save a self-referential archive and I can’t think what I could be doing wrong or how to begin to debug it.
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