<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/SectionedFetchResults/Section",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI21SectionedFetchResultsV7SectionV"
  },
  "title" : "SectionedFetchResults.Section"
}
-->

# SectionedFetchResults.Section

A collection of fetched results that share a specified identifier.

```
@MainActor @preconcurrency struct Section
```

## Overview

Examine a `Section` instance to find the entities that satisfy a
[`SectionedFetchRequest`](/documentation/SwiftUI/SectionedFetchRequest) predicate, and that have a particular property
with the value stored in the section’s [`id`](/documentation/SwiftUI/SectionedFetchResults/Section/id)
parameter. You specify which property by setting the fetch request’s
`sectionIdentifier` parameter during initialization, or by modifying
the corresponding [`SectionedFetchResults`](/documentation/SwiftUI/SectionedFetchResults) instance’s
[`sectionIdentifier`](/documentation/SwiftUI/SectionedFetchResults/sectionIdentifier) property.

Obtain specific sections by treating the fetch results as a collection.
For example, consider the following property declaration
that fetches `Quake` managed objects that the
<doc://com.apple.documentation/documentation/SwiftUI/loading-and-displaying-a-large-data-feed>
sample code project defines to store earthquake data:

```
@SectionedFetchRequest<String, Quake>(
    sectionIdentifier: \.day,
    sortDescriptors: [SortDescriptor(\.time, order: .reverse)]
)
private var quakes: SectionedFetchResults<String, Quake>
```

Get the first section using a subscript:

```
let firstSection = quakes[0]
```

Alternatively, you can loop over the sections to create a list of
sections.

```
ForEach(quakes) { section in
    Text("Section \(section.id) has \(section.count) elements")
}
```

The sections also act as collections, which means
you can use elements like the
<doc://com.apple.documentation/documentation/Swift/Collection/count>
property in the example above.

## Topics

### Identifying the section

[`let id: SectionIdentifier`](/documentation/SwiftUI/SectionedFetchResults/Section/id)

The value that all entities in the section share for a specified
key path.

### Getting indices

[`var startIndex: Int`](/documentation/SwiftUI/SectionedFetchResults/Section/startIndex)

The index of the first entity in the section.

[`var endIndex: Int`](/documentation/SwiftUI/SectionedFetchResults/Section/endIndex)

The index that’s one greater than that of the last entity in the
section.

### Getting results

[`subscript(Int) -> Result`](/documentation/SwiftUI/SectionedFetchResults/Section/subscript(_:))

Gets the entity at the specified index within the section.

## Relationships

### Conforms To

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

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

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

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

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

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

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

---

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)