---
title: "setIndex(_:forSubKeyPath:)"
framework: intents
role: symbol
role_heading: Instance Method
path: "intents/inparameter/setindex(_:forsubkeypath:)"
---

# setIndex(_:forSubKeyPath:)

Specifies which item of an array or ordered set to use for the parameter.

## Declaration

```swift
func setIndex(_ index: Int, forSubKeyPath subKeyPath: String)
```

## Parameters

- `index`: The index of an object in the array or ordered set.
- `subKeyPath`: The path to the property containing an array or ordered set. For example, the key path for the messages property of an doc://com.apple.sirikit/documentation/Intents/INSearchForMessagesIntentResponse object would be the string messages.

## Discussion

Discussion When the key path for a parameter contains an array or ordered set, use this method to specify which object in that array or ordered set to use.

## See Also

### Managing Indexed Values

- [index(forSubKeyPath:)](intents/inparameter/index(forsubkeypath:).md)
