title: Core Data deleteObject: sets attributes to nil
body: <p>I am implementing an undo/redo mechanism in my app.  This works fine for lots of cases.  However, I can't undo past deleteObject:.  the object is correctly saved in the undo queue, and I get it back and reinsterted into the Core Data stack just fine when calling undo.  The problem is that all it's attributes are getting set to nil when I delete it.</p>
  
  <p>I have an entity "Canvas" with a to-many relationship called "graphics" to a "Graphic" entity, which has its inverse set to "canvas".  Deleting a Graphic, then inserting it back, doesn't work.  Here's the code (the redo method is basically the same):</p>
  
  <pre><code>- (void)deleteGraphic:(id)aGraphic {
   //NSLog(@"undo drawing");
   //Prepare the undo/redo
   [self.undoManager beginUndoGrouping];
   [self.undoManager setActionName:@"Delete Graphic"];
  
   [[self.detailItem valueForKey:@"graphics"] removeObject:aGraphic];
   [[self managedObjectContext] deleteObject:aGraphic];
  
   //End undo/redo
   [self.undoManager registerUndoWithTarget:self selector:@selector(insertGraphic:) object:aGraphic];
   [self.undoManager endUndoGrouping];
  
   NSLog(@"graphics are %@", [self sortedGraphics]);
  
   //Update drawing
   [self.quartzView setNeedsDisplay];
  }
  </code></pre>
  
  <p>and here's the wierdness:</p>
  
  <p>Before delete:</p>
  
  <pre><code>graphics are (
  &lt;NSManagedObject: 0x1cc3f0&gt; (entity: Graphic; id: 0x1c05f0 &lt;x-coredata:///Graphic/t840FE8AD-F2E7-4214-822F-7994FF93D4754&gt; ; data: {
  canvas = 0x162b70 &lt;x-coredata://A919979E-75AD-474D-9561-E0E8F3388718/Canvas/p20&gt;;
  content = &lt;62706c69 73743030 d4010203 04050609 0a582476 65727369 6f6e5424 746f7059 24617263 68697665 7258246f 626a6563 7473&gt;;
  frameRect = nil;
  label = nil;
  order = 1;
  path = "(...not nil..)";
  traits = "(...not nil..)";
  type = Path;
  })
  </code></pre>
  
  <p>After redo:</p>
  
  <pre><code>graphics are (
  &lt;NSManagedObject: 0x1cc3f0&gt; (entity: Graphic; id: 0x1c05f0 &lt;x-coredata:///Graphic/t840FE8AD-F2E7-4214-822F-7994FF93D4754&gt; ; data: {
  canvas = nil;
  content = nil;
  frameRect = nil;
  label = nil;
  order = 0;
  path = nil;
  traits = nil;
  type = nil;
  }),
  </code></pre>
  
  <p>You can see it's the same object, just totally bleached by Core Data.  The relationship delete rouls apparently have nothing to do with it as I've set them to "No Action" in a test.</p>