开发者

CoreData MultiThreading Delete

开发者 https://www.devze.com 2023-04-11 13:20 出处:网络
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

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 data开发者_运维问答base. 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.


You need to pass the objectIds 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]
0

精彩评论

暂无评论...
验证码 换一张
取 消