Structure

SectionedFetchResults.Section

A collection of fetched results that share a specified identifier.

Declaration 宣言

struct Section

Overview 概要

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 parameter. You specify which property by setting the fetch request’s sectionIdentifier parameter during initialization, or by modifying the corresponding SectionedFetchResults instance’s 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 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 operations like the count method in the example above.

Topics 話題

Identifying the Section

Getting Indices

Subscripts 添え字

Type Aliases 型エイリアス

Relationships 関係

See Also 参照

Configuring the Associated Sectioned Fetch Request