About Incremental Stores

An incremental store is a persistent store in Core Data that allows you to access its content little by little. You can bring into memory just the data your program needs to operate, rather than the entire contents of the store. Similarly, an incremental store writes just the data that changed, rather than overwriting the entire backing data store. Core Data also supports atomic persistent stores (see Atomic Store Programming Topics), which read the entire data store into memory and write the entire store to disk.

Incremental stores work well for apps that use large amounts of data, where storing the entirety in memory is not feasible. In contrast, atomic stores work well for apps that use small amounts of data.

At a Glance

The Core Data framework is responsible for all of the managed objects in memory, leaving only the implementation of the persistence mechanism to your incremental store. Your incremental store must perform the following tasks:

Use Cases

Use incremental stores when:

For example, you might use a custom incremental store to query an unsupported database format, interface with legacy code, or bridge with cross-platform code bases. Implement your own custom incremental store when one of these situations applies and the built-in store types do not meet your needs.

Alternatives

Core Data is an object graph and data persistence framework that provides functionality to perform complex operations like relational mapping, storage, undo management, and schema migration. Core Data is divided into several layers; each layer abstracts out a specific set of functionality: Managed object contexts hold in-memory representations of the backing data, persistent stores act as adaptors to backing data stores, and persistent store coordinators bridge contexts with persistent stores. This guide focuses on the persistent store layer. See Core Data Programming Guide for more information on using the Core Data framework.

Core Data includes several built-in persistent stores to support atomic and incremental object persistence:

Atomic:

Incremental:

How to Use This Document

Use this guide as a reference and as an implementation strategy when implementing your own incremental store. Follow the strategies and best practices presented in this guide to create incrementally runnable, testable code and to avoid common pitfalls.

Prerequisites

You should be comfortable with the Core Data framework before implementing a custom incremental store. To learn about the basic features of Core Data, read Technology Overview in Core Data Programming Guide.

See Also

You’ll find other excellent resources in Apple’s developer libraries. Here are a few whose topics are related to the content in this book.