---
title: responses
framework: corespotlight
role: symbol
role_heading: Instance Property
path: corespotlight/csuserquery/responses-swift.property
---

# responses

The matching results and suggestions for the current query string.

## Declaration

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

## Mentioned in

Building a search interface for your app

## Discussion

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: 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     } }

## See Also

### Executing the query automatically

- [suggestions](corespotlight/csuserquery/suggestions-swift.property.md)
- [CSUserQuery.Responses](corespotlight/csuserquery/responses-swift.struct.md)
- [CSUserQuery.Suggestions](corespotlight/csuserquery/suggestions-swift.struct.md)
- [CSUserQuery.Item](corespotlight/csuserquery/item.md)
- [CSUserQuery.Suggestion](corespotlight/csuserquery/suggestion.md)
