Efficient storage of large amounts of data in iOS

I am creating an application that has a recording function that records user interaction over time. As time passes, I fill the array in memory with state objects representing the current state of user input. A typical entry will result in approximately 5k of these objects.

Then I archive this data using NSKeyedArchiver archiveRootObject: toFile: This works great, but the file size is very large (3.5 megabytes or so). My question is this:

Are there any nested file size overhead related to file archiving? Can I save this data using much less disk space if I use SQLite or even copy my own file format? Or is this the only way to reduce the size of the data disk in order to reduce the bit depth of the numbers that I store?

+2
source share
3 answers

If your issue is performance related, Core Data gives you more granularity. You can lazily download and save in parts during the execution of the application, as well as download / save the entire graph of 3.5Mb objects.

If your problem is with file size, this is binary plist format , and this is SQLite file format . But more important than the overhead is how complicated the translation between your object graph and the Core Data model is.

You may also be interested in this comparison of speed and performance for several file formats: https://github.com/eishay/jvm-serializers/wiki/ Not sure if everything is C, C ++ or objective-C.

+2
source

3.5 MB is not a very large file. However, if your application needs to download or save a 3.5 MB file all the time, then using Core Data is much smarter, as it allows you to save only the data that has been changed and only extract the parts that interest you - - not all this every time.

+2
source

If the focus is on storage, there will be little difference in b / w sqlite and main data.

I had to store UIViewControllers with state in the application, as a result of which I did not save serialized objects, but only the most specific properties were saved and created a class that read this data and redirected these objects.

The property map was then saved in csv [admittedly very difficult to manage, but small, like everyone else), and then compressed.

0
source

All Articles