Contents

About Incremental Stores

Describes how to implement a Core Data incremental store.

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:

Validate and load the metadata that the persistent store coordinator uses to identify and keep track of your store

Fulfill fetch and save requests sent by a managed object context

Realize value and relationship faults fired by a managed object

Note: The NSIncrementalStore class is a subclass of the NSPersistentStore class. There is no need to override the methods that you must otherwise override for a subclass of NSPersistentStore . These methods have been implemented for you in the NSIncrementalStore class.

Use Cases

Use incremental stores when:

Your data is too large to load into memory all at once

Retrieving your data is an expensive or time-consuming operation

Access to your data is dependent on device conditions (network connectivity, resource availability, and so on)

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:

In-Memory Store ( NSInMemoryStoreType )

XML Store ( NSXMLStoreType )

Binary Store ( NSBinaryStoreType )

Incremental:

SQLite Store ( NSSQLiteStoreType )

Note: The XML store is not available on iOS.

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 <!--a target="_self" -->Technology Overview<!--/a--> 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.

Core Data Programming Guide

Atomic Store Programming Topics

Predicate Programming Guide

Next

Copyright © 2016 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2016-03-21