• 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 merge and "statement is still active" error?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data merge and "statement is still active" error?


  • Subject: Re: Core Data merge and "statement is still active" error?
  • From: Ben Trumbull <email@hidden>
  • Date: Thu, 5 Jun 2008 22:01:54 -0400


On Jun 5, 2008, at 7:49 PM, Michael Link wrote:


On Jun 5, 2008, at 4:37 PM, Ben Trumbull wrote:


On Jun 3, 2008, at 8:15 PM, Michael Link wrote:

Is there a reason you're not using Core Data's - mergeChangesFromContextDidSaveNotification: ?

If the object is modified (inserted, update, or deleted), you should pass in YES to -refreshObject:mergeChanges:

Actually I am using mergeChangesFromContextDidSaveNotification:, I am calling refreshObject:mergeChanges: with NO on the NSUpdatedObjectsKey objects just before as this avoids the problem of Bug 5937572.

You shouldn't call -refreshObject:mergeChanges:NO on an object with changes (passing YES is okay). The reason for this is if the object is deleted or inserted, nuking that state is just plain weird. The graph of objects will not behave they way you would wish. A nuked inserted object is stuck in limbo, and a nuked deleted object can be a stale pointer for any of the objects related to it across inverse relationships. Nuking an updated object also has a high probability of corrupting the relationship state for other objects with relationships to it.


Since the objects on the main thread aren't supposed to have changes, skipping the changed ones shouldn't be a burden.

I should skip using -refreshObject:mergeChanges:NO on any object that is in NSUpdatedObjectsKey?

No, by "changed" I mean returns YES to any of: -isDeleted, - isInserted, -isUpdated


In your mergeChangesFromContextDidSaveNotification callback, you save the document. If you do that first, and then call - refreshObject:mergeChanges:NO on all the objects in the notification that don't have changes, and then call the MOC's mergeChangesFromContextDidSaveNotification (since this will send notifications for any observing controllers), it appears to work around your first problem.

Obviously, that's way more convoluted than it ought to be.

- Ben

_______________________________________________

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


References: 
 >re: Core Data merge and "statement is still active" error? (From: Ben Trumbull <email@hidden>)
 >Re: Core Data merge and "statement is still active" error? (From: Michael Link <email@hidden>)
 >Re: Core Data merge and "statement is still active" error? (From: Ben Trumbull <email@hidden>)
 >Re: Core Data merge and "statement is still active" error? (From: Michael Link <email@hidden>)

  • Prev by Date: Converting a MenuRef to a NSMenu
  • Next by Date: Re: knowing when WebView is done
  • Previous by thread: Re: Core Data merge and "statement is still active" error?
  • Next by thread: IBOutlet, multiple nibs, method duplication
  • Index(es):
    • Date
    • Thread