Initializes a predicate that evaluates using a specified block object and bindings dictionary.


init(block: @escaping (Any?, [String : Any]?) -> Bool)



The block is applied to the object to be evaluated.

The block takes two arguments:


The object to be evaluated.


The substitution variables dictionary. The dictionary must contain key-value pairs for all variables in the receiver.

The block returns true if the evaluatedObject evaluates to true, otherwise false.

Return Value

A new predicate by that evaluates objects using block.


In macOS 10.6 and later, Core Data supports block-based predicates in the in-memory and atomic stores, but not in the SQLite-based store.

See Also

Creating a Predicate

init(format: String, argumentArray: [Any]?)

Initializes a predicate by substituting the values in a given array into a format string and parsing the result.

init(format: String, arguments: CVaListPointer)

Initializes a predicate by substituting the values in an argument list into a format string and parsing the result.

func withSubstitutionVariables([String : Any]) -> Self

Returns a copy of the predicate with the predicate's variables substituted by values specified in a given substitution variables dictionary.

init(value: Bool)

Creates and returns a predicate that always evaluates to a given Boolean value.

init?(fromMetadataQueryString: String)

Initializes a predicate with a metadata query string.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software