Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the advantages of NSBinaryStoreType?

NSPersistentStoreCoordinator has four store types: NSSQLiteStoreType, NSXMLStoreType, NSBinaryStoreType, and NSInMemoryStoreType. I understand XML store can be handy for debugging, or In Memory when you need a volatile cache.

What are the real advantages of using the Binary Store type?

like image 251
Esteban Bouza Avatar asked May 17 '13 14:05

Esteban Bouza


1 Answers

NSBinaryStoreType will occupy the least disk space, and will load the fastest, of the atomic store types.

Atomic store types load every Core Data object in the document at once, so once the doc is loaded, it's all in memory and you never hit the disk again until you hit save:. The NSSQLiteStoreType will occupy binary-like disk space, will load extremely fast and can live in arbitrarily limited memory, but the document file needs to be available on disk as long as the app has it open -- it can't be deleted or overwritten by another app while you're using it, which the atomic types will tolerate. There are also some limitations of the SQL store type as laid out here -- in general atomic store types perform much faster and give you more features, at the expense of an ever increasing memory footprint.

NSBinaryStoreType is by no means the most efficient atomic store type possible, it is not compressed in any way. You could write your own gzipped XML or JSON store type which would probably occupy the less disk space than either NSSQLiteStoreType or NSBinaryStoreType, at the expense of load/save speed.

like image 65
iluvcapra Avatar answered Oct 21 '22 21:10

iluvcapra