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

# init(code:userActivity:)

Initializes the response object with the specified code and user activity object.

## Declaration

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

## Parameters

- `code`: The response code indicating your success or failure in confirming or handling the intent. For a list of possible values, see doc://com.apple.sirikit/documentation/Intents/INSearchForPhotosIntentResponseCode.
- `userActivity`: The user activity object to use when launching your app. Provide an object if you want to add information specific to your app. If you specify nil, the system automatically creates a user activity object for you, sets its type to the class name of the intent, and fills it with an doc://com.apple.sirikit/documentation/Intents/INInteraction object containing the intent and your response.

## Discussion

Discussion After initializing the object, assign a value to the searchResultsCount property indicating the number of photos that match the search parameters.
