Best practices for exporting core data objects

I need to export multiple objects with my relationships in order to import them to another iOS device. For instance:

A.relationship1 <------>> B.relationship1 (one to many) B.relationship2 <-------> C.relationship1 (one to one) 

Is there a way to serialize / deserialize (or other methods) to export / import โ€œeasilyโ€ a fragment of the underlying data model (objects and its relationships obtained using the resulting result controller) by serializing the entire data packet (NSData or something), deserializing and pasting it into context (import).

Please point me in the right direction. Thanks in advance.

+6
source share
1 answer

The best way for you, I think, is to convert your Core Data objects to JSON, save it and then decode it.

Here is an absolute excellent working code for both encoding and decoding Marcus Zarra

JSON and basic data on iPhone

+1
source

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


All Articles