Contents

init(sortDescriptors:predicate:animation:)

Creates a fetch request based on a predicate and reference type sort parameters.

Declaration

@MainActor @preconcurrency init(sortDescriptors: [NSSortDescriptor], predicate: NSPredicate? = nil, animation: Animation? = nil)

Parameters

  • 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:sortDescriptors:predicate:animation:) initializer instead. If you need more control over the fetch request configuration, use init(fetchRequest:animation:).

See Also

Creating a fetch request