<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreSpotlight",
  "identifier" : "/documentation/CoreSpotlight/CSUserQuery/responses-swift.property",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Core Spotlight",
      "CoreSpotlight"
    ],
    "preciseIdentifier" : "s:So11CSUserQueryC13CoreSpotlightE9responsesAbCE9ResponsesVvp"
  },
  "title" : "responses"
}
-->

# responses

The matching results and suggestions for the current query string.

```
var responses: CSUserQuery.Responses { get }
```

## Discussion

Getting the value of this property starts the query and begins the
delivery of responses. Typically, you get this property as part of a
`for..in` loop to iterate over the responses, as shown in the following
example:

```swift
var results: [CSUserQuery.Item] = []
var suggestions: [CSUserQuery.Suggestion] = []
let query = CSUserQuery(userQueryString: searchText, userQueryContext: queryContext)

for try await element in query.responses {
    switch(element) {
        case .item(let item):
            self.results.append(item)
            break
        case .suggestion(let suggestion):
            self.suggestions.append(suggestion)
            break
        @unknown default:
            break
    }
}
```

---

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)