<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SiriKit",
  "identifier" : "/documentation/Intents/INParameter/setIndex(_:forSubKeyPath:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Intents"
    ],
    "preciseIdentifier" : "c:objc(cs)INParameter(im)setIndex:forSubKeyPath:"
  },
  "title" : "setIndex(_:forSubKeyPath:)"
}
-->

# setIndex(_:forSubKeyPath:)

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

```
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 [`INSearchForMessagesIntentResponse`](/documentation/Intents/INSearchForMessagesIntentResponse) object would be the string `messages`.

## 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.

---

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)