Contents

fetch(_:batchSize:)

Returns a collection of typed models, in batches, which match the criteria of the specified fetch descriptor.

Declaration

func fetch<T>(_ descriptor: FetchDescriptor<T>, batchSize: Int) throws -> FetchResultsCollection<T> where T : PersistentModel

Parameters

  • descriptor:

    A fetch descriptor that provides the configuration for the fetch.

  • batchSize:

    The maximum number of models to include in each batch.

Return Value

The collection of typed models that satisfy the criteria of the fetch descriptor. If no models match the criteria, the collection is empty.

Discussion

As you access the models in the returned collection (either sequentially, or directly using subscripting), the context automatically fetches the necessary batches.

See Also

Fetching models