---
title: SectionedResults
framework: SwiftData
role: symbol
role_heading: Structure
platforms: [iOS 27.0+, iPadOS 27.0+, Mac Catalyst 27.0+, macOS 27.0+, tvOS 27.0+, visionOS 27.0+, watchOS 27.0+]
path: swiftdata/sectionedresults
---

# SectionedResults

A RandomAccessCollection of ResultsSection instances representing sectioned query results.

## Declaration

```swift
struct SectionedResults<Element, SectionTitle> where Element : PersistentModel, SectionTitle : Hashable
```

## Overview

Overview SectionedResults is the result type for sectioned @Query properties. Iterating it yields sections; each section is itself a RandomAccessCollection of model elements. Use subscript(sectionTitle:) for O(1) lookup by section title. @Query(sort: \.name, sectionBy: \.category) var items: SectionedResults<Item, String>

ForEach(items) { section in              // section: ResultsSection<Item, String>     Section(section.title) {             // "Work", "Personal", …         ForEach(section) { item in … }   // item: Item     } }

// O(1) named lookup let workCount = items[sectionTitle: "Work"]?.count ?? 0

## Topics

### Instance Properties

- [sectionTitles](swiftdata/sectionedresults/sectiontitles.md)

### Instance Methods

- [contains(sectionTitle:)](swiftdata/sectionedresults/contains(sectiontitle:).md)
- [index(ofSectionTitled:)](swiftdata/sectionedresults/index(ofsectiontitled:).md)

### Subscripts

- [subscript(sectionTitle:)](swiftdata/sectionedresults/subscript(sectiontitle:).md)

### Default Implementations

- [Equatable Implementations](swiftdata/sectionedresults/equatable-implementations.md)

## Relationships

### Conforms To

- [BidirectionalCollection](swift/bidirectionalcollection.md)
- [Collection](swift/collection.md)
- [Equatable](swift/equatable.md)
- [RandomAccessCollection](swift/randomaccesscollection.md)
- [Sequence](swift/sequence.md)
