I've got a NSPersistentDocument. I have read the Concurrency with Core Data in the Core Data Programming Guide and am following the typically recommended approach which is to create separate managed object context (MOC) for each thread, but to share a single persistent store coordinator (PSC)

I am using a NSOperation which does create its own MOC and does share the PSC with the main thread. The operation adds some objects and I call [MOC save:&error]. This succeeds and a NSManagedObjectContextDidSaveNotification is generated and I get this on the main thread. I then call the mergeChangesFromContextDidSaveNotification method while handling the notification on the main thread. I can see the objects saved in my document.

The problem then is that my NSPersistentDocument generates an error which says:

"The document "xxx" could not be saved. The file has been changed by another application"

Of course, the other application is the NSOperation which did change the document.

How can I correctly avoid the error?

Thank you.


_______________________________________________

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

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

Reply via email to