<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftData",
  "identifier" : "/documentation/SwiftData/ResultsObserver/indexPath(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftData"
    ],
    "preciseIdentifier" : "s:9SwiftData15ResultsObserverC9indexPath3for10Foundation05IndexF0VSgx_tF"
  },
  "title" : "indexPath(for:)"
}
-->

# indexPath(for:)

Returns the index path of the given element within the sectioned results.

```
final func indexPath(for element: Element) -> IndexPath?
```

## Parameters

`element`

An element to locate within the sectioned results.

## Return Value

An index path where `[0]` is the section index and `[1]` is the item
index, or `nil` if the object is not found or [`sections`](/documentation/SwiftData/ResultsObserver/sections) is `nil`.

---

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)