Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best practice to store complex data structure in core data on iOS?

I have a complex data structure along with some other data fields that used for query that need to save with core data for future use. I am thinking of serialize the complex data structure into JSON string and store as one string field in core data entities instead of create an entity with many properties. This complex data structure is purely saved for future use, there is no query on any properties required, however I do need to query on the other data fields so I am thinking of use core data.

I am wondering is this (store as JSON string) the best practice or there is a better solution for this?

like image 498
Robert Mao Avatar asked Oct 28 '25 02:10

Robert Mao


1 Answers

Short answer, no, that would not be the best solution. If you don't want to store the object with a data model you create then Core Data will give you very little benefit. You'll basically have a bunch of opaque objects that you won't be able to distinguish until you deserialize its json string. If that's sufficient for your needs, then I'd recommend just archiving the objects to disk and skipping the overhead of Core Data.

like image 191
Paul Tiarks Avatar answered Oct 30 '25 17:10

Paul Tiarks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!