---
title: CLSDataStore
framework: classkit
role: symbol
role_heading: Class
path: classkit/clsdatastore
---

# CLSDataStore

A container for all the ClassKit data in your app.

## Declaration

```swift
class CLSDataStore
```

## Overview

Overview 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 save(completion:) method to commit the changes, and propagate them through the network.

## Topics

### Accessing the shared data store

- [shared](classkit/clsdatastore/shared.md)

### Managing the delegate

- [Building missing contexts](classkit/building-missing-contexts.md)
- [delegate](classkit/clsdatastore/delegate.md)
- [CLSDataStoreDelegate](classkit/clsdatastoredelegate.md)

### Accessing specific contexts and activities

- [mainAppContext](classkit/clsdatastore/mainappcontext.md)
- [activeContext](classkit/clsdatastore/activecontext.md)
- [runningActivity](classkit/clsdatastore/runningactivity.md)
- [fetchActivity(for:completion:)](classkit/clsdatastore/fetchactivity(for:completion:).md)
- [completeAllAssignedActivities(matching:)](classkit/clsdatastore/completeallassignedactivities(matching:).md)

### Finding contexts that match criteria

- [contexts(matchingIdentifierPath:completion:)](classkit/clsdatastore/contexts(matchingidentifierpath:completion:).md)
- [contexts(matching:completion:)](classkit/clsdatastore/contexts(matching:completion:).md)
- [CLSPredicateKeyPath](classkit/clspredicatekeypath.md)

### Removing contexts

- [remove(_:)](classkit/clsdatastore/remove(_:).md)

### Saving changes

- [save(completion:)](classkit/clsdatastore/save(completion:).md)

### Instance Methods

- [checkIsAssignedDocument(_:completion:)](classkit/clsdatastore/checkisassigneddocument(_:completion:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Essentials

- [Enabling ClassKit in your app](classkit/enabling-classkit-in-your-app.md)
- [ClassKit Environment Entitlement](bundleresources/entitlements/com.apple.developer.classkit-environment.md)
- [Incorporating ClassKit into an Educational App](classkit/incorporating-classkit-into-an-educational-app.md)
- [ClassKit UI](classkitui.md)
