• 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: Core Data : Undo Delete : Cannot fulfill a fault
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data : Undo Delete : Cannot fulfill a fault


  • Subject: Re: Core Data : Undo Delete : Cannot fulfill a fault
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 29 Sep 2011 11:20:14 -0700

On Sep 29, 2011, at 06:22 , Jerry Krinock wrote:

> That's interesting that this occurs even if the object has never even been faulted in.  Further confirmation of my  conclusion, and yours, that Core Data is saving attributes elsewhere.  I recall that the heavy lifter in a Core Data undo invocation seems to be -[NSManagedObjectContext _undoUpdates], which has no parameters.  So, it's like NSManagedObjectContext has its own internal undo stack which, among other things, stashes the attributes of faulted objects, in case they need to be resurrected to fulfill an undo.  In my corner case, at least one of those attributes are unavailable 59% of the time.
>
> If anyone knows any more about this mechanism, the info would be appreciated.

I think the answer to your original question is that You're Doing It Wrong™. :)

I'm pretty sure (though I never really thought about it before today) that Core Data undo *doesn't* work across 'save:' boundaries. The documentation for [NSManagedObjectContext undo:] says this:

> "Sends an undo message to the receiver’s undo manager, asking it to reverse the latest uncommitted changes applied to objects in the object graph."


Note that word "uncommitted". After 'save:', all changes are committed, so you're not permitted to undo past that point. At least, that's how I read it.

I think I can also advance an explanation why it works part of the time. This is based on my Core Data entrail-readings from Leopard days, so it's only guesswork, and things may have changed since then. Take this with a grain of salt.

Core Data accesses property data at least 3 levels: (#1) what's in the persistent store (i.e. on disk); (#2) what pointed to by fault-fulfilled objects (i.e. value objects in memory); (#3) an internal cache of property data previous read from the store. This last is not tied to the existence of any particular object, it's just a historical cache.

If you delete an object (thereby allowing its property values to be flushed from memory), then try to undo the deletion, the object may not be able to be restored to its original state from #2, because those value objects have been released. If you've *also* done a 'save:' after the deletion but before the undo, that's certainly the case, plus the object can't be restored to its original state from #1, because it doesn't exist there any more.

However, the object *can* (apparently, I'm guessing) be restored from #3 *if* its properties happen to still be in the cache. In many, many cases of undoing fairly soon after the deletion (perhaps 41% of the time in your testing scenario), the property data will still be available. The rest of the time, well, you'll suck a big fulfillment failure.

If I'm right, you should be clearing the undo stack at a save, at least if there are deleted objects in the picture.

Alternately, I'm completely wrong.


_______________________________________________

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: Core Data : Undo Delete : Cannot fulfill a fault
      • From: Jim Correia <email@hidden>
    • Re: Core Data : Undo Delete : Cannot fulfill a fault
      • From: Jerry Krinock <email@hidden>
References: 
 >Core Data : Undo Delete : Cannot fulfill a fault (From: Jerry Krinock <email@hidden>)
 >Re: Core Data : Undo Delete : Cannot fulfill a fault (From: Richard Somers <email@hidden>)
 >Re: Core Data : Undo Delete : Cannot fulfill a fault (From: Jerry Krinock <email@hidden>)
 >Re: Core Data : Undo Delete : Cannot fulfill a fault (From: Dave Fernandes <email@hidden>)
 >Re: Core Data : Undo Delete : Cannot fulfill a fault (From: Jerry Krinock <email@hidden>)
 >Re: Core Data : Undo Delete : Cannot fulfill a fault (From: Dave Fernandes <email@hidden>)
 >Re: Core Data : Undo Delete : Cannot fulfill a fault (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Receiving Crash Reports
  • Next by Date: Re: NSDocument Serialization (-performSynchronousFileAccessUsingBlock: and friends)
  • Previous by thread: Re: Core Data : Undo Delete : Cannot fulfill a fault
  • Next by thread: Re: Core Data : Undo Delete : Cannot fulfill a fault
  • Index(es):
    • Date
    • Thread