Assume I do:
ThingWhichKnowsItsContainer *a = [[ ThingWhichKnowsItsContainer alloc ] init];
NSArray *array = @[ a ];
a.theContainer = array;
NSData *d = [ NSKeyedArchiver archivedDataWithRootObject: array];
NSArray *unarchivedArray = [ MyVeryOwnUnarchiver: unarchiveObjectWithData: d ];

MyVeryOwnUnarchiver has a method like:
- (id)objectForArchiveIndex: (NSNumber *n)
{
        id result = dictionaryOfThingsDone[n];
        if ( result == nil )    //      create and remember result
        {
                //      assume n stands for the array:
                NSMutableArray *tempMutable = [ NSMutableArray array];

                dictionaryOfThingsDone[n] = tempMutable; 
                // needed to be done here so that later stuff (like 
ThingWhichKnowsItsContainer) do not create another array, but use this one.

                for all archiveIndices "i" in "n" do:
                {
                        id x = [ self objectForArchiveIndex: i ];
                        [ tempMutable addObject: x ];
                }
                result = [ tempMutable copy];   // result must be NSArray, not 
NSMutableArray
        };
        
        return result;
}

When it comes to ThingWhichKnowsItsContainer it will (using my 
dictionaryOfThingsDone) set myContainer = tempMutable.

So I get an unarchivedArray which contains a ThingWhichKnowsItsContainer which 
knows tempMutable but NOT it's container which is unarchivedArray.

How to fix this?

NSKeyedUnarchiver probably just uses something like: [tempMutable 
makeImmutable] but this is not a public method.

Gerriet.


_______________________________________________

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