---
title: CKSyncEngineState
framework: cloudkit
role: symbol
role_heading: Class
path: cloudkit/cksyncenginestate
---

# CKSyncEngineState

An object that manages the sync engine’s state.

## Declaration

```occ
@interface CKSyncEngineState : NSObject
```

## Overview

Overview To reliably and consistently sync your app’s data, a sync engine keeps a record of several important pieces of data, such as server changes tokens (for databases and record zones), subscription identifiers, the most recent userRecordID, and so on. This class automatically manages that state on behalf of your app, but there are certain elements you can modify. For example, you control the list of pending changes to send to the iCloud servers and manipulate that list using the addPendingDatabaseChanges: and addPendingRecordZoneChanges: methods. If there aren’t any scheduled sync operations when you invoke these methods, the engine automatically schedules one. An engine’s state changes periodically and, when it does, the sync engine dispatches an event of type  CKSyncEngineStateUpdateEvent to your delegate. The event contains an instance of CKSyncEngineStateSerialization and, on receipt of such an event, it’s your responsibility to persist the serialized state to disk so that it’s available across app launches. On the next initialization of the sync engine, you provide the most recently persisted state as part of the engine’s configuration. For more information, see initWithDatabase:stateSerialization:delegate:.

## Topics

### Accessing pending changes

- [hasPendingUntrackedChanges](cloudkit/cksyncenginestate/haspendinguntrackedchanges.md)
- [pendingDatabaseChanges](cloudkit/cksyncenginestate/pendingdatabasechanges.md)
- [pendingRecordZoneChanges](cloudkit/cksyncenginestate/pendingrecordzonechanges.md)

### Modifying pending changes

- [addPendingDatabaseChanges:](cloudkit/cksyncenginestate/addpendingdatabasechanges:.md)
- [removePendingDatabaseChanges:](cloudkit/cksyncenginestate/removependingdatabasechanges:.md)
- [CKSyncEnginePendingZoneDelete](cloudkit/cksyncenginependingzonedelete.md)
- [CKSyncEnginePendingZoneSave](cloudkit/cksyncenginependingzonesave.md)
- [CKSyncEnginePendingDatabaseChange](cloudkit/cksyncenginependingdatabasechange.md)
- [addPendingRecordZoneChanges:](cloudkit/cksyncenginestate/addpendingrecordzonechanges:.md)
- [removePendingRecordZoneChanges:](cloudkit/cksyncenginestate/removependingrecordzonechanges:.md)
- [CKSyncEnginePendingRecordZoneChange](cloudkit/cksyncenginependingrecordzonechange.md)

### Instance Properties

- [zoneIDsWithUnfetchedServerChanges](cloudkit/cksyncenginestate/zoneidswithunfetchedserverchanges.md)

## Relationships

### Inherits From

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

## See Also

### Accessing the engine’s attributes

- [database](cloudkit/cksyncengine-4b4w9/database.md)
- [state](cloudkit/cksyncengine-4b4w9/state.md)
