init(fetchRequest:managedObjectContext:sectionNameKeyPath:cacheName:)
Returns a fetch request controller initialized using the given arguments.
Declaration
init(fetchRequest: NSFetchRequest<ResultType>, managedObjectContext context: NSManagedObjectContext, sectionNameKeyPath: String?, cacheName name: String?)Parameters
- fetchRequest:
The fetch request used to get the objects.
The fetch request must have at least one sort descriptor. If the controller generates sections, the first sort descriptor in the array is used to group the objects into sections; its key must either be the same as
sectionNameKeyPathor the relative ordering using its key must match that usingsectionNameKeyPath. - context:
The managed object against which
fetchRequestis executed. - sectionNameKeyPath:
A key path on result objects that returns the section name. Pass
nilto indicate that the controller should generate a single section.The section name is used to pre-compute the section information.
If this key path is not the same as that specified by the first sort descriptor in
fetchRequest, they must generate the same relative orderings. For example, the first sort descriptor infetchRequestmight specify the key for a persistent property;sectionNameKeyPathmight specify a key for a transient property derived from the persistent property. - name:
The name of the cache file the receiver should use. Pass
nilto prevent caching.Pre-computed section info is cached to a private directory under this name. If Core Data finds a cache stored with this name, it is checked to see if it matches the
fetchRequest. If it does, the cache is loaded directly—this avoids the overhead of computing the section and index information. If the cached information doesn’t match the request, the cache is deleted and recomputed when the fetch happens.
Return Value
The receiver initialized with the specified fetch request, context, key path, and cache name.
See Also
Related Documentation
- Core Data Programming Guide