<!--
{
  "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/ResultsSection",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftData"
    ],
    "preciseIdentifier" : "s:9SwiftData14ResultsSectionV"
  },
  "title" : "ResultsSection"
}
-->

# ResultsSection

A section of fetched results grouped by a common section key path value.

```
struct ResultsSection<Element, SectionTitle> where Element : PersistentModel, SectionTitle : Hashable
```

## Overview

Each section represents a group of elements that share the same value for the
`sectionBy` key path used at creation.

You access sections by iterating a [`SectionedResults`](/documentation/SwiftData/SectionedResults) value returned by a sectioned
`@Query`. Each section conforms to `RandomAccessCollection` — iterate it directly to
access its elements, and use [`title`](/documentation/SwiftData/ResultsSection/title) (or [`id`](/documentation/SwiftData/ResultsSection/id)) to access the section grouping value.

```
@Query(sort: \.name, sectionBy: \.category)
var items: SectionedResults<Item, String>

ForEach(items) { section in
    Section(section.title) {          // "Work", "Personal", …
        ForEach(section) { item in … } // Item elements
    }
}
```

## Topics

### Accessing section properties

[`var id: SectionTitle`](/documentation/SwiftData/ResultsSection/id)

The unique identifier for the section, which is its [`title`](/documentation/SwiftData/ResultsSection/title).

### Instance Properties

[`let title: SectionTitle`](/documentation/SwiftData/ResultsSection/title)

The identifier of the section.

### Default Implementations

[Equatable Implementations](/documentation/SwiftData/ResultsSection/Equatable-Implementations)

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`Identifiable`](/documentation/Swift/Identifiable)

[`BidirectionalCollection`](/documentation/Swift/BidirectionalCollection)

[`Sequence`](/documentation/Swift/Sequence)

[`RandomAccessCollection`](/documentation/Swift/RandomAccessCollection)

[`Collection`](/documentation/Swift/Collection)

---

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)