<!--
{
  "availability" : [
    "iOS: 10.0.0 - 15.0.0",
    "iPadOS: 10.0.0 - 15.0.0",
    "macCatalyst: 13.1.0 - 15.0.0",
    "macOS: 10.12.0 - 12.0.0",
    "tvOS: 10.0.0 - 15.0.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 3.0.0 - 8.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "CloudKit",
  "identifier" : "/documentation/CloudKit/CKFetchDatabaseChangesOperation/fetchDatabaseChangesCompletionBlock",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "CloudKit"
    ],
    "preciseIdentifier" : "c:objc(cs)CKFetchDatabaseChangesOperation(py)fetchDatabaseChangesCompletionBlock"
  },
  "title" : "fetchDatabaseChangesCompletionBlock"
}
-->

# fetchDatabaseChangesCompletionBlock

The closure to execute when the operation finishes.

```
var fetchDatabaseChangesCompletionBlock: ((CKServerChangeToken?, Bool, (any Error)?) -> Void)? { get set }
```

## Discussion

The closure returns no value and takes the following parameters:

- The change token to store and use in subsequent instances of [`CKFetchDatabaseChangesOperation`](/documentation/CloudKit/CKFetchDatabaseChangesOperation).
- A Boolean value that indicates whether this is the final database change. If [`fetchAllChanges`](/documentation/CloudKit/CKFetchDatabaseChangesOperation/fetchAllChanges) is <doc://com.apple.documentation/documentation/Swift/false>, it’s the app’s responsibility to create additional instances of [`CKFetchDatabaseChangesOperation`](/documentation/CloudKit/CKFetchDatabaseChangesOperation) to fetch further changes.
- An error object that contains information about a problem, or `nil` if CloudKit successfully retrieves the database changes.

> Note: The change token and error parameters are mutually exclusive — that is, the closure provides one of them but not both.

Your app is responsible for saving the change token at the end of the operation and providing it to future uses of [`CKFetchDatabaseChangesOperation`](/documentation/CloudKit/CKFetchDatabaseChangesOperation). If the server returns a [`CKError.Code.changeTokenExpired`](/documentation/CloudKit/CKError/Code/changeTokenExpired) error, the [`previousServerChangeToken`](/documentation/CloudKit/CKFetchDatabaseChangesOperation/previousServerChangeToken) value is stale and your app needs to clear its local cache and refetch the database changes, starting with a `nil` change token.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)