A container for all the ClassKit data in your app.


@interface CLSDataStore : NSObject


Use the ClassKit data store to build and access contexts (CLSContext instances) that you use to advertise your app’s assignable content. Contexts in turn provide access to activities (CLSActivity instances) and activity items (CLSScoreItem, CLSBinaryItem, and CLSQuantityItem instances) that you use to record progress through assignments. You don’t instantiate a data store yourself. Instead, use the single shared data store instance throughout your app.

The data store provides access to the app’s one and only main context through the mainAppContext property. This property acts as the root context in your context hierarchy that you can use as a starting point when searching for descendant contexts.

To build contexts, you adopt the CLSDataStoreDelegate protocol in one of your classes, typically one that exists for the lifetime of your app, and assign an instance of that class as the shared data store’s delegate property. Then, when the data store needs a context that it’s never seen before, it asks your delegate to build it.

After you make changes to any context, activity, or activity item, call the data store’s saveWithCompletion: method to commit the changes, and propagate them through the network.


Accessing the Shared Data Store


The shared data store object.

Managing the Delegate

Building Missing Contexts

Create and initialize missing contexts.


The data store delegate instance.


An interface the data store uses to request new contexts.

Accessing Specific Contexts and Activities


The app’s top-level context.


The currently active context.


The currently running activity within the currently active context.

- completeAllAssignedActivitiesMatching:

Marks all of the assigned and currently active activities for the given context path as complete.

Finding Contexts That Match Criteria

- contextsMatchingIdentifierPath:completion:

Fetches all the contexts along a given identifier path.

- contextsMatchingPredicate:completion:

Fetches all the contexts matching a predicate.


The set of possible key paths you use to search for contexts.

Removing Contexts

- removeContext:

Marks a context for removal.

Saving Changes

- saveWithCompletion:

Saves any changes you’ve made in the data store.


Inherits From

See Also


Enabling ClassKit in Your App

Prepare your app and your development environment to adopt ClassKit.

ClassKit Environment Entitlement

The ClassKit development or production environment for an education app that works with the Schoolwork app.

Incorporating ClassKit into an Educational App

Walk through the process of setting up assignments and recording student progress.