<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CloudKit",
  "identifier" : "/documentation/CloudKit/CKSyncEngine-5sie5/RecordZoneChangeBatch/init(pendingChanges:recordProvider:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "CloudKit"
    ],
    "preciseIdentifier" : "s:8CloudKit12CKSyncEngineC21RecordZoneChangeBatchV14pendingChanges14recordProviderAESgSayAC07PendingefG0OG_So8CKRecordCSgSo0N2IDCYaYbXEtYacfc"
  },
  "title" : "init(pendingChanges:recordProvider:)"
}
-->

# init(pendingChanges:recordProvider:)

Creates a batch of records to modify using the provided record zone changes.

```
init?(pendingChanges: [CKSyncEngine.PendingRecordZoneChange], recordProvider: @Sendable (CKRecord.ID) async -> CKRecord?) async
```

## Parameters

`pendingChanges`

The record zone changes to process.

`recordProvider`

A closure that returns the record for the specified record identifier.

## Return Value

The batch of records to modify, or `nil` if there are no pending changes.

## Discussion

This method iterates over `pendingChanges` and adds the necessary information to the new batch, until there are no more changes or the size of the batch reaches the maximum limit.
If the type of change is a record save, the method asks the specified `recordProvider` closure for that record. If the closure returns `nil`, the method skips that change.

---

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)