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 (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 [EMAIL PROTECTED]

Reply via email to