init(predicate:sortBy:)
Creates a fetch descriptor with the specified predicate that, optionally, arranges the fetched models in a particular order.
Declaration
init(predicate: Predicate<T>? = nil, sortBy: [SortDescriptor<T>] = [])Parameters
- predicate:
The logical condition that determines whether the fetch includes a specific model in its results. The default value is
nil. - sortBy:
The array of sort descriptors that tell the fetch how to order its results. The default value is an empty array.
Discussion
If you don’t specify a predicate, any fetch using this descriptor will return all models of the associated type. If you expect the number of fetched models to be high, use fetchLimit and fetchOffset to break those results into smaller, more efficient batches.