• 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: NSManagedObjectContext -insertObject: Cancels Prior Deletion -- BUT!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSManagedObjectContext -insertObject: Cancels Prior Deletion -- BUT!


  • Subject: Re: NSManagedObjectContext -insertObject: Cancels Prior Deletion -- BUT!
  • From: Jerry Krinock <email@hidden>
  • Date: Fri, 8 May 2009 13:00:01 -0700

Conclusion.  Here's what I believe to be the "missing documentation"...

***

"You can use -insertObject: to cancel a prior deletion, however if certain operations are performed after the deletion and before the restoring -insertObject:, the attributes of the deleted/inserted object will all be set to nil. These certain operations include, but may not be limited to,

   -[NSManagedObjectContext executeFetchRequest:error:]
   -[NSManagedObjectContext save:]

Regarding the former, note that the deleted objects need not be (and will not be, because they are deleted) included in the fetch results in order to have their attributes hosed.

This applies both to explicit deletions performed by -[NSManagedObject deleteObject:], and implicit deletions resulting from the action of a Cascade Delete Rule when a related object is deleted.

Because it may be difficult to keep track of when the certain operations are going to be performed, re-inserting deleted objects is not recommended."

***

I'll file the above as a bug report next week. Anyone who can further clarify, please reply.

For my application, where I am deleting a parent and have children cascade-deleted, I added some extra code to make a collection of children that I don't want delete before deleting their parents, move these children to a temporary "foster parent", delete the old parents, then move the children to their new parent.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSManagedObjectContext -insertObject: Cancels Prior Deletion -- BUT!
      • From: Adam Swift <email@hidden>
References: 
 >NSManagedObjectContext -insertObject: Cancels Prior Deletion? (From: Jerry Krinock <email@hidden>)
 >Re: NSManagedObjectContext -insertObject: Cancels Prior Deletion? (From: Dave Fernandes <email@hidden>)
 >Re: NSManagedObjectContext -insertObject: Cancels Prior Deletion -- BUT! (From: Jerry Krinock <email@hidden>)
 >Re: NSManagedObjectContext -insertObject: Cancels Prior Deletion -- BUT! (From: Alexander Spohr <email@hidden>)
 >Re: NSManagedObjectContext -insertObject: Cancels Prior Deletion -- BUT! (From: Jerry Krinock <email@hidden>)
 >Re: NSManagedObjectContext -insertObject: Cancels Prior Deletion -- BUT! (From: Jim Correia <email@hidden>)
 >Re: NSManagedObjectContext -insertObject: Cancels Prior Deletion -- BUT! (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Renaming a file repositions icon in Finder
  • Next by Date: Re: NSManagedObjectContext -insertObject: Cancels Prior Deletion -- BUT!
  • Previous by thread: Re: NSManagedObjectContext -insertObject: Cancels Prior Deletion -- BUT!
  • Next by thread: Re: NSManagedObjectContext -insertObject: Cancels Prior Deletion -- BUT!
  • Index(es):
    • Date
    • Thread