Initializer

init(sectionIdentifier:sortDescriptors:predicate:animation:)

Creates a sectioned fetch request based on a section identifier, a predicate, and value type sort parameters.

Declaration 宣言

init(sectionIdentifier: KeyPath<Result, SectionIdentifier>, sortDescriptors: [SortDescriptor<Result>], predicate: NSPredicate? = nil, animation: Animation? = nil)
Available when SectionIdentifier conforms to Hashable and Result inherits NSManagedObject.

Parameters パラメータ

sectionIdentifier

A key path that SwiftUI applies to the Result type to get an object’s section identifier.

sortDescriptors

An array of sort descriptors that define the sort order of the fetched results.

predicate

An NSPredicate instance that defines logical conditions used to filter the fetched results.

animation

The animation to use for user interface changes that result from changes to the fetched results.

Discussion 議論

The request gets the entity type from the Result instance by calling that managed object’s entity() type method. If you need to specify the entity type explicitly, use the init(entity:sectionIdentifier:sortDescriptors:predicate:animation:) initializer instead. If you need more control over the fetch request configuration, use init(fetchRequest:sectionIdentifier:animation:). For reference type sort descriptors, use init(sectionIdentifier:sortDescriptors:predicate:animation:).

See Also 参照

Creating a Fetch Request フェッチリクエストを作成する