Contents

fetchRequestFromTemplate(withName:substitutionVariables:)

Returns a copy of the fetch request template with the variables substituted by values from the substitutions dictionary.

Declaration

func fetchRequestFromTemplate(withName name: String, substitutionVariables variables: [String : Any]) -> NSFetchRequest<any NSFetchRequestResult>?

Parameters

  • name:

    A string containing the name of a fetch request template.

  • variables:

    A dictionary containing key-value pairs where the keys are the names of variables specified in the template; the corresponding values are substituted before the fetch request is returned. The dictionary must provide values for all the variables in the template.

Return Value

A copy of the fetch request template with the variables substituted by values from variables.

Discussion

The variables dictionary must provide values for all the variables. If you want to test for a nil value, use [NSNull null].

This method provides the usual way to bind an “abstractly” defined fetch request template to a concrete fetch. For more details on using this method, see Creating Predicates.

See Also

Manipulating fetch request templates