---
title: "handleEvent(_:syncEngine:)"
framework: cloudkit
role: symbol
role_heading: Instance Method
path: "cloudkit/cksyncenginedelegate-1q7g8/handleevent(_:syncengine:)"
---

# handleEvent(_:syncEngine:)

Tells the delegate to handle the specified sync event.

## Declaration

```swift
func handleEvent(_ event: CKSyncEngine.Event, syncEngine: CKSyncEngine) async
```

## Parameters

- `event`: Information about the event. An event may occur for a number of reasons, such as when new data is available or when the device’s iCloud account changes. For more information, see doc://com.apple.cloudkit/documentation/CloudKit/CKSyncEngine-5sie5/Event.
- `syncEngine`: The sync engine that generates the event.

## Discussion

Discussion important: On receipt of a CKSyncEngine.Event.stateUpdate(_:) event, you must persist the attached state to disk alongside your app data. The sync engine requires you to provide it with the most recent serialized state at initialization, and it’s your responsibility to make sure this is available across app launches. The sync engine provides events serially; your delegate won’t receive the subsequent event until it finishes processing the current one and returns from this method.

## See Also

### Handling sync events

- [CKSyncEngine.Event](cloudkit/cksyncengine-5sie5/event.md)
- [CKSyncEngineEventType](cloudkit/cksyncengineeventtype.md)
