Predicate
public protocol Predicate : AsyncPredicate
The Predicate
protocol is used to define the structre that must be implemented by concrete predicates.
-
A type that provides information about what kind of values the predicate can be evaluated with.
Declaration
Swift
associatedtype InputType
-
Returns a
Boolean
value that indicates whether a given input matches the conditions specified by the receiver.Declaration
Swift
func evaluate(with input: InputType) -> Bool
Parameters
input
The input against which to evaluate the receiver.
Return Value
true
if input matches the conditions specified by the receiver,false
otherwise.
-
evaluate(with:queue:completionHandler:)
Extension methodAsynchronous evaluates whether a given input matches the conditions specified by the receiver, then calls a handler upon completion.
Declaration
Swift
public func evaluate(with input: InputType, queue: DispatchQueue = .main, completionHandler: @escaping (_ matches: Bool) -> Void)
Parameters
input
The input against which to evaluate the receiver.
queue
The queue on which the completion handler is executed. If not specified, it uses
DispatchQueue.main
.completionHandler
The completion handler to call when the evaluation is complete. It takes a
Bool
parameter:matches
true
if input matches the conditions specified by the receiver,false
otherwise.