---
title: "fetchLastClientState(completionHandler:)"
framework: corespotlight
role: symbol
role_heading: Instance Method
path: "corespotlight/cssearchableindex/fetchlastclientstate(completionhandler:)"
---

# fetchLastClientState(completionHandler:)

Fetches the app’s most recent client state information asynchronously.

## Declaration

```swift
func fetchLastClientState(completionHandler: @escaping @Sendable (Data?, (any Error)?) -> Void)
```

```swift
func fetchLastClientState() async throws -> Data
```

## Parameters

- `completionHandler`: The block to call when the request has been journaled by the index, which means that the index makes a note that it has to perform this operation. Note that the request may not have completed. The block receives the following parameter:

## Mentioned in

Adding your app’s content to Spotlight indexes

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func fetchLastClientState() async throws -> Data For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously.

## See Also

### Batching index updates

- [beginBatch()](corespotlight/cssearchableindex/beginbatch().md)
- [endBatch(withClientState:completionHandler:)](corespotlight/cssearchableindex/endbatch(withclientstate:completionhandler:).md)
- [endIndexBatch(expectedClientState:newClientState:completionHandler:)](corespotlight/cssearchableindex/endindexbatch(expectedclientstate:newclientstate:completionhandler:).md)
