CLSDataStore
A container for all the ClassKit data in your app.
Declaration
class CLSDataStoreOverview
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
Managing the delegate
Accessing specific contexts and activities
mainAppContextactiveContextrunningActivityfetchActivity(for:completion:)completeAllAssignedActivities(matching:)