• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to unarchive?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to unarchive?


  • Subject: How to unarchive?
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Thu, 28 Feb 2013 14:36:10 +0700

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 (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

  • Prev by Date: Re: archiving report
  • Next by Date: Re: archiving report
  • Previous by thread: Re: Build setting for embedded dylib?
  • Next by thread: positional information about terms in a search kit index
  • Index(es):
    • Date
    • Thread