---
title: updateHandler
framework: healthkit
role: symbol
role_heading: Instance Property
path: healthkit/hkanchoredobjectquery/updatehandler
---

# updateHandler

Handler for monitoring updates to the HealthKit store.

## Declaration

```swift
var updateHandler: (@Sendable (HKAnchoredObjectQuery, [HKSample]?, [HKDeletedObject]?, HKQueryAnchor?, (any Error)?) -> Void)? { get set }
```

## Discussion

Discussion If this property is set to nil, the anchor query automatically stops as soon as it finishes calculating the initial results. If this property is not nil, the query behaves similarly to the observer query: it continues to run, monitoring the HealthKit store. The system executes the update handler on a background queue whenever matching samples are saved to or deleted from the HealthKit store.
