One Logo Pool Ball
SwiftUI · IOS API REFERENCE

SectionedFetchResults.Section

struct · iOS 15.0+ · SDK 27.1

@MainActor @preconcurrency struct Section

A collection of fetched results that share a specified identifier. Examine a `Section` instance to find the entities that satisfy a ``SectionedFetchRequest`` predicate, and that have a particular property with the value stored in the section's ``id-swift.property-1h7qm`` parameter. You specify which property by setting the fetch request's `sectionIdentifier` parameter during initialization, or by modifying the corresponding ``SectionedFetchResults`` instance's ``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-4l4qk> property in the example above.

Members (0)

This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.

Skipped declarations

4 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

SectionedFetchResults.Section.startIndex

The containing type needs Swift generic type arguments. (no canonical witness for Result)

SectionedFetchResults.Section.endIndex

The containing type needs Swift generic type arguments. (no canonical witness for Result)

SectionedFetchResults.Section.subscript(_:)

This declaration needs Swift generic type arguments. (no canonical witness for Result)

SectionedFetchResults.Section.id

The containing type needs Swift generic type arguments. (no canonical witness for Result)

All SwiftUI types →