On 2011 Sep 30, at 14:39, Quincey Morris wrote:

> It would be interesting to know this: if you manually break the parent-child 
> relationships before actually deleting either the parent or the child, does 
> the order of the deletions matter?

Invoking either -setParent:nil or -setChildren:nil on the object before 
invoking -[NSManagedObjectContext deleteObject:] fixes the problem.

> Also, do you invoke 'processPendingChanges' yourself during the enumeration, 
> or do you just let it happen automatically?

I do not processPendingChanges when deleting an object.  Doing so after 
invoking -[NSManagedObjectContext deleteObject:] is another way to fix the 
problem.

> Also, what's the delete rule for the child's "parent" relationship? Surely 
> not "Cascade"?

Nullify.

> If the delete rule for the parent's "children" relationship is "Cascade", 
> then you're (conceptually) asking for the child to be deleted twice (once 
> when the parent is explicitly deleted, once when the child is explicitly 
> deleted during the enumeration). I've no doubt this is safe enough in terms 
> of the deletions themselves, but I'm wondering if the way the sequence of 
> undo steps get recorded for this just isn't robust enough in the case where 
> the deleted objects are expunged (faulted out and removed from the persistent 
> store) before the undo happens.

Yes, remember that inserting the objects and saving are necessary in the Steps 
to Reproduce.

Pruning and unpruning trees is often hairy.  You think you've thought through 
all of the possibilities, but then one day you find yourself sitting on a 
disconnected limb.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to