Atomic Store Fundamentals
This article describes the fundamental concepts that underly the atomic store.
Introduction
Core Data provides four native types of persistent store:
SQLite
Binary
XML
In-Memory
These store types each offer different benefits and tradeoffs, and are described in Persistent Store Features. The Binary and XML stores are "atomic” stores—they must be read and written in their entirety, unlike the SQLite store which can be modified piecemeal, one record at a time if you wish.
Core Data manages all interaction with these stores, translating insertions, deletions, and updates of managed object into, from, and in, a managed object context. Core Data also manages the file formats.
The atomic store API allows you to create a custom store format for your data, and interact with the data using standard Core Data APIs. This in turn allows you to leverage Core Data in your application but use either an existing—perhaps legacy—file format, or to define a new file format that may be used by external applications that do not use Core Data. For example, you might create a "generic" store type such as for HTML or comma-separated values, or some other intermediary type for integration with a third-party. It is important though to note that the atomic store API does not provide support for integration with client-server relational databases or similar SQL-based stores.
If you implement a custom store type, it is typically tied to a specific managed object model that describes the schema encoded in the store.
Atomic Store Classes
There are three classes you use when implementing a custom store:
This is the abstract base class for all Core Data stores.
This is a subclass of
NSPersistentStore
.This is a concrete class that provides a basic representation of a “node” in your store.
Of these, the only one you need to subclass is NSAtomicStore
. It is an abstract superclass for you to subclass to create atomic stores. It provides default implementations of some utility methods. You cannot directly subclass NSPersistentStore
. You can subclass NSAtomicStoreCacheNode
to provide specialized behavior if necessary.
Implementation Requirements
NSAtomicStore
is a subclass of NSPersistentStore
. Both classes require you to implement various methods.
In a subclass of NSPersistentStore
, you must override the following methods:
In a subclass of NSAtomicStore
, you must override the following methods:
Copyright © 2011 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2011-10-12