• 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
Re: Key Archiving a NSMutableDictionary object corrupts its embedded NSMutableDictionary data object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Key Archiving a NSMutableDictionary object corrupts its embedded NSMutableDictionary data object


  • Subject: Re: Key Archiving a NSMutableDictionary object corrupts its embedded NSMutableDictionary data object
  • From: "Martin" <email@hidden>
  • Date: Mon, 05 Jul 2004 17:39:48 -0700

Hi Frederick,

I have also encountered this problem when archiving NSMutableDictionary objects. My dictionary mapped NSNumber objects to a custom class I had written.

What works for me is to simply make an immutable copy of the dictionary for serialization, eg:

NSDictionary* map = [mutableMap copy];
[coder encodeObject:map forKey:@"key"];
[map release];

And on deserialization:

map = [c decodeObjectForKey:@"key"];
mutableMap = [map mutableCopy];

I realize this is not the most efficient, but the only thing that worked for me in the end. Best,

~Martin


On July 04 2004, Frederick C. Lee <email@hidden> wrote:

>Greetings:
>
>The scenario:
>
> I'm trying to archive a NSMutableDictionary of country objects, the
>key being the country name. Each country object (model) contains
>assorted country-related instance variables, including an embedded
>NSMutableDictionary of city objects that are roughly patterned the same
>way as their parent country.
>
>
>{Country Dictionary}
> ['country name' --> (country object)]
> {City Dictionary}
> ['city name' -->(city
>object)]
> ...
> ...
>
>
>I'm using key-archiving to store the country dictionary.
>
>Problem: The embedded city dictionary always returns corrupt. Or
>perhaps is written corrupted before the read. However, I'm able to
>read the keys of the apparent corrupted NSMutableDictionary.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Use different window than File Owner's in NIB
  • Next by Date: [ANN] F-Script screenshots posted
  • Previous by thread: Re: Use different window than File Owner's in NIB
  • Next by thread: [ANN] F-Script screenshots posted
  • Index(es):
    • Date
    • Thread