CoreData: error: Mutation of a managed object after its removal from the context

I created a simple application that retrieves some JSON and stores data inside Core Data.

After the initial installation on the simulator or device, all operations with the master data are fine, but when I restart, I get the following error message:

2016-07-02 13:23:53.925 En Yakın[84775:5379467] CoreData: error: Mutating a managed object 0x79736290 <x-coredata:///Category/t4B10F995-A717-4DB8-9E87-8A1C079D45D42> (0x79736250) after it has been removed from its context. 

There is nothing wrong with the visual. All data is presented as expected, and features of the application.

I debugged the problem. If I comment on the JSON extraction function and make the application use what is inside Core Data after the first run, error messages are not displayed. But re-extracting the application is a misunderstanding with my underlying data stack (implemented as a singleton object).

How do I change the implementation of master data?

Update

I believe that I traced this issue. I save the thumbnails of about 6 KB that I downloaded. I found out that saving images will lead to a loss in Core Data performance. But are thumbnails of this size also problematic? If I remove the entity image assignment, the errors disappear. Should I store them inside the file structure?

+2
source share
1 answer

The error is interesting:

<x-coredata:///Category/t4B10F995-A717-4DB8-9E87-8A1C079D45D42>

Note the lowercase t before the GUID. This means that this object is new and has not been saved. Therefore, if you do not throw away the unsaved context of the managed entity after each use, a fully operational strategy, you have a state mismatch.

An easy way to solve your problem is to either give more save or work in the child context that you throw out before each new selection.

+2
source

Source: https://habr.com/ru/post/1014198/


All Articles