title: iOS NSKeyedArchiver -- NSMutableDictionary coming back as NSPlaceholderDictionary?
body: <p>I have a large and complex object graph.  I have implemented NSCoding to archive and unarchive the object graph.  Normally, everything works fine.  But under certain highly reproducible circumstances, an NSMutableDictionary that I archive gets unarchived as an NSPlaceholderDictionary.  This is a private subclass of NSMutableDictionary and represents an uninitialized dictionary.  It does not respond to any of the usual NSDictionary methods. </p>
  
  <p>I am wondering if anyone has run across a similar problem.  If so, were you able to solve it?  And how?</p>
  
  <p>EDIT: One thing I can say about the circumstances is that the dictionary itself is deeply nested, with lots of contained dictionaries and arrays.  And deep inside it is a pointer to another object that is in the process of being created.  The object graph is a tree.  Most objects in the tree contain weak references to their parents.  The problem occurs at n layers deep in the tree.  At the time of the crash, the stack looks something like this [I've simplified it]:</p>
  
  <pre><code>0. crash because dictionary is a placeholder
  1. depth n initWithCoder -- decode a deep and large dictionary which, prior to encoding contained reference to object at depth n+4.  Said object has not yet been decoded.
  2. Apple methods 
  3. depth n+1 initWithCoder -- decode reference to parent
  4. 38 frames of apple methods for very deeply nested dictionary
  5. depth n-1 initWithCoder -- decode a deeply nested dictionary.  Among other things, the dictionary contains a reference to the level n+1 object [inside a lot of nested dictionaries and arrays]
  6. Apple methods
  7. depth n-2 object initWithCoder -- decode reference to array containing its children
  </code></pre>