Master data: combining multiple managed objects Contexts and deleting objects

I have an iPhone project in which I have a series of managed objects in the context of a managed object in the main thread of an application. In a separate thread, I import new objects from the web server into the second context of the managed object.

If the import goes without errors, I keep the import context. This calls the contextDidSave from which I am calling mergeChangesFromContextDidSaveNotification. The two contexts merge normally. So far so good.

My desired functionality is that all objects located in the original MOC, but not in the imported MOC, should be deleted (the idea is that the user updates the data and therefore the old data should be deleted), but merging seems to be simple combines 2 MOC.

Please can you advise if there is a way to control the merger of two MOCs so that those who are not in one are deleted in the other?

+3
source share
3 answers

When creating a new moc, it has access to all old objects, so you can handle the deletion in the background thread as part of the import.

+1
source

, , . , "", . , , , . , .

0

, , "prepareForDelet", "delete" YES. , , , NO. , ,

0

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


All Articles