Do I need to call NSManagedObjectContext save: for storage in memory?

I am using CoreData in my persistent storage application like NSInMemoryStoreType .

Do you have to call NSManagedObjectContext save: with this type of storage? Does save: transfer to NSManagedObjectContext do anything to hold in memory?

Apple documentation just states:

save:
An attempt to make unsaved changes to registered objects in their persistent storage.

What does this really mean in the context of storage in memory?

+6
source share
2 answers

I could not find the documentation, but I am sure that it is still needed.

Core Data has an external interface (represented by the context of the managed entity) and a persistent backend ("storage"). A persistent backend is usually a file, but it can just be inside the memory for NSInMemoryStoreType .

For all Core Data functions to work, the two parts must be separated from each other, and you click on the backend (persistent data) from the external interface (pending changes) using the save operation.

Note that for the same storage (backend) there can be several contexts of managed objects (frontends), and each of them has different pending changes. Note that there are methods such as hasChanges and NSUndoManager for each managed object context. It still works with storage in memory.

Some information is also here.

+3
source

save: checks attribute and constraint constraints.

+1
source

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


All Articles