iOS - is there any framework serving huge amount of arbitrary binary data as plist or xml?

StackOverflow https://stackoverflow.com/questions/9215191

  •  28-04-2021
  •  | 
  •  

Question

I know it is not good idea to use plist or xml for huge amount of arbitrary binary data for some performance reasons.

Suppose my data format is an array of (some strings, an integer, binary data) where the size of binary data is over a few megabytes(not fixed) and the arrary size is hundreds say. I want to serialize and store whole data in one file on my Documents directory and read only some of them from that file into memory. So, I first thought using plist is a way to achieve the requirement, but as mentioned above it is not good way.

One way to avoid the problem is to use paths of binary data instead of binary data and then I can use Core Data or something similar. But, then that does not satisfy the requirement.

I spent several days to find an appropriate framework, it seems there is none. Should I build my own encoding and deconding methods in my case? NSArchiving is enough to achieve my requirement?

No correct solution

OTHER TIPS

NSCoding actually just creates a binary Plist, so the performance will be similar (XML Plists embedded in your app get converted to binary when you build).

(FYI, if you take an NSCoded file and put .plist on the end, you can open it in the Plist editor and see all the properties, although the contents aren't really human-readable like a regular plist),

Plists are pretty fast though - probably fast enough for a file that's a few MB in size. Have you actually tried just using a Plist for this?

Another alternative is to use a JSON file and load it with JSONKit. JSONKit have benchmarked their performance as being faster at loading than even a binary plist: http://www.cocoanetics.com/2011/03/json-versus-plist-the-ultimate-showdown/

If that's still not fast enough, the next best option would be to store it in an SQLLite database, although that's a lot more work. Databases are generally much better for loading only part of the file though because you won't have to load the whole lot into memory, you can just grab the parts you need.

You don’t want to use XML or text Plists. I think I would try NSCoding & friends first, see the Archives and Serialization Guide. But if you really need to store the whole thing into one single file and then read just parts of it, I think you’re on your own. How about a database?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top