---
title: "add(pendingDatabaseChanges:)"
framework: cloudkit
role: symbol
role_heading: Instance Method
path: "cloudkit/cksyncengine-5sie5/state-swift.class/add(pendingdatabasechanges:)"
---

# add(pendingDatabaseChanges:)

Adds the specified database changes to the state.

## Declaration

```swift
final func add(pendingDatabaseChanges: [CKSyncEngine.PendingDatabaseChange])
```

## Parameters

- `pendingDatabaseChanges`: An array of database changes.

## Discussion

Discussion Use this method to enable the sync engine to manage your pending database changes. For example, when someone makes a change that your app needs to send to the server, use this method to record the change. If there are no scheduled sync operations when you invoke this method, the sync engine automatically schedules one to send the changes. After the engine sends those changes, it notifies your app’s sync delegate with an event of type CKSyncEngine.Event.SentDatabaseChanges. The sync engine maintains a consistent collection of tracked pending changes, deduplicating them as necessary. The engine removes changes from the list as it sends them, but retains any that fail due to a recoverable error, such as a network issue or exceeding the rate limit. note: The order in which you apply database changes is important. For example: If you add .saveZone(zoneA) then .deleteZone(zoneA), the sync engine discards the save and sends only the delete change. If you add .deleteZone(zoneA) then .saveZone(zoneA), the sync engine discards the delete and sends only the save change.

## See Also

### Manipulating pending changes

- [remove(pendingDatabaseChanges:)](cloudkit/cksyncengine-5sie5/state-swift.class/remove(pendingdatabasechanges:).md)
- [CKSyncEngine.PendingDatabaseChange](cloudkit/cksyncengine-5sie5/pendingdatabasechange.md)
- [add(pendingRecordZoneChanges:)](cloudkit/cksyncengine-5sie5/state-swift.class/add(pendingrecordzonechanges:).md)
- [remove(pendingRecordZoneChanges:)](cloudkit/cksyncengine-5sie5/state-swift.class/remove(pendingrecordzonechanges:).md)
- [CKSyncEngine.PendingRecordZoneChange](cloudkit/cksyncengine-5sie5/pendingrecordzonechange.md)
