Core Data & NSPersistentDocument & Concurrency
Core Data & NSPersistentDocument & Concurrency
- Subject: Core Data & NSPersistentDocument & Concurrency
- From: email@hidden
- Date: Fri, 01 Feb 2013 13:13:14 -0700
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 (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