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

# index(forSubKeyPath:)

The index into the array at the specified portion of the key path.

## Declaration

```swift
func index(forSubKeyPath subKeyPath: String) -> Int
```

## Parameters

- `subKeyPath`: The key path to a property containing an array or ordered set. For example, when retrieving a message from a set of search results, specify the string messages.

## Return Value

Return Value The index of the item in the array.

## Discussion

Discussion For intents or responses that contain an array of values, use this method to determine which object in the array was specified. For example, if a parameter represented the first object in an array of messages returned by a search, specifying the string messages would return the value 0.

## See Also

### Managing Indexed Values

- [setIndex(_:forSubKeyPath:)](intents/inparameter/setindex(_:forsubkeypath:).md)
