But what if I want to save my model objects that are not dependent on the storage mechanism that is used (maybe I will reuse them in a project where I dont need persistency at all)?
With master data, persistence is just an option, it is not required because Core Data is not primarily a persistence API. Instead, it is an object graph management API designed to provide a complete layer of the Design-View-Controller application model. This true function controls the objects in the graph to accurately model / simulate real-world objects, conditions or events and the relationships between them.
You change the save settings at the permanent repository coordinator level. You have the option of using sqlite repository, binary store, xml plist repository, or in-memory repository, which, as the name implies, is not really a "persistent" repository. You also have the opportunity to write your own store. For more information, see Atomic Store programming topics .
You really need a managed entity context to get any value from Core Data. Instead of calling it "NSManagedObjectContext", they should have called it "NSManagedObjectManager" because it is all automatic maintenance of the object schedule. If you want to duplicate this functionality, you will have to basically write your own manager class.
In my opinion, the best way to provide insurance flexibility that you are trying to write in a serialization method to a common data format such as JSON. Then, if you need to switch to another save option, you can simply convert the graph of the kernel data object to JSON and send it anywhere.
However, I really would not bother if you already do not know for sure that such functionality is needed. It is very, very rare. It is better to code only for known requirements, and then just record the time for new requirements when they really appear.
source share