Contents

init(_:)

Creates a predicate by converting an existing predicate.

Declaration

convenience init?<Input>(_ predicate: Predicate<Input>) where Input : NSObject

Parameters

  • predicate:

    The predicate to convert.

Return Value

The converted predicate, or nil if conversion fails.

Discussion

Only a subset of predicates that can be expressed by Predicate are convertible to NSPredicate. Predicates that include operations like the following can’t be converted:

  • Accessing key paths for properties that aren’t exposed to the Objective-C runtime.

  • Capturing values of types that aren’t supported by NSPredicate, like custom Swift structures.

  • Using some functions or operators, like performing collection operations on a nonstring value.

See Also

Creating a Predicate