Can anyone recommend a memory-efficient way to append data to an archive using NSKeyArchiver?
I have an array which collects objects and makes them available to the app as an in-memory cache. In order to avoid eating more and more memory, I'd like to archive this array to a file every so often, keeping a single cache file (as opposed to creating separate ones).
One way to do this would be to unarchive the exiting file to a tempArray, than add the items in the existing array to it:
[tempArray addObjectsFromArray:array];
and then archive array:
[NSKeyedArchiver archiveRootObject:tempArray toFile:file];
This approach kind of beats its own purpose, because you have to read the entire archive to memory before you archive the new data.
Anyone can recommend a more elegant solution?