---
title: "init(code:userActivity:)"
framework: intents
role: symbol
role_heading: Initializer
path: "intents/inlistcarsintentresponse/init(code:useractivity:)"
---

# init(code:userActivity:)

Creates a response object with the specified code and user activity.

## Declaration

```swift
init(code: INListCarsIntentResponseCode, userActivity: NSUserActivity?)
```

## Parameters

- `code`: The response code that indicates success or failure when confirming or handling the intent. For a list of possible values, see doc://com.apple.sirikit/documentation/Intents/INListCarsIntentResponseCode.
- `userActivity`: A user activity that the system passes to your app if it launches as a result of this response. Use an activity if you need to provide additional information specific to your app. If you specify nil, the system automatically: Creates a user activity for you. Sets the activity’s type to the class name of the intent it’s handling. Sets the activity’s doc://com.apple.documentation/documentation/Foundation/NSUserActivity/interaction property to an instance of doc://com.apple.sirikit/documentation/Intents/INInteraction that contains the intent and your response.
