Reputation: 4167
In my iPad application, I am using Multithreading to read data from my database and hence I am using different manged object contexts as explained Fred McCann's blog
The problem I am facing is while deleting items from the database. When I try to delete, I get the error that the managedObjectContext cannot delete another objectContext's data. How do I solve this problem?
It would be great is someone could help me out with this.
Upvotes: 2
Views: 158
Reputation: 15376
You need to pass the objectId
s around and then get that object from the other context.
NSManagedObject *object = // get the object...
NSManagedObjectID *objectID = object.objectID;
// Pass to other context on other thread...
// ...
NSManagedObject *sameObjectDifferentContext = [managedObjectContext objectWithID:objectID]
Upvotes: 2