Illegal attempt to establish a relationship 'xyz' between objects in different contexts

后端 未结 6 1175
傲寒
傲寒 2020-12-23 13:44

I am using Apple\'s CoreDataBooks sample application as a basis for pulling data into a secondary managed object context in the background, and then merging tha

6条回答
  •  心在旅途
    2020-12-23 14:16

    book *book = [mainContext ........]   //Get book from default context
    
    NSManagedObjectID *objectId = [book objectID];
    
    Book *tmpBook = [tmpContext objectWithID:objectId]; //Now book has the legal relationship
    

提交回复
热议问题