title: CoreData: "Dangling reference to an invalid object." error
body: <p>I'm working on a Cocoa-Touch app, it uses CoreData and has some NSPersistentObject subclasses generated by the XCode model editor.</p>
  
  <p>I've noticed that recently, when saving the context I get an error which has as user info the following part:</p>
  
  <pre><code>(gdb) po ui {
      "Dangling reference to an invalid object." = &lt;null&gt;;
      NSAffectedObjectsErrorKey = &lt;dump #1 of someObject&gt;;
      NSLocalizedDescription = "Operation could not be completed. (Cocoa error 1550.)";
      NSValidationErrorKey = &lt;someKey pointing to someObject #1&gt;;
      NSValidationErrorObject = &lt;dump #2 of someOtherObject which points to the dump #1 object&gt;;
      NSValidationErrorValue = { &lt;list of someMoreObjects&gt; };
  }
  </code></pre>
  
  <p>There are on other keys in the user info dictionary.</p>
  
  <p>All the dumps I get are valid objects, I've verified them all.</p>
  
  <p><code>NSValidationErrorObject</code> is an object which has an <code>NSSet</code> which contains objects of types dumped in <code>NSAffectedObjectsErrorKey</code> and <code>NSValidationErrorValue</code>. But all these objects are valid.</p>
  
  <p>Furthermore, this happens randomly, sometimes it happens, sometimes not, and sometimes the list dumped in <code>NSValidationErrorValue</code> is longer, sometimes shorter.</p>
  
  <p>I have no clue why this is happening, or what exactly the error is. Does anyone know what's going on? Any ideas what might cause this bizarre error?</p>