- iOS 9.0+
- macOS 10.11+
- Mac Catalyst 13.0+Beta
- tvOS 9.0+
GKNSPredicate class is a specialized subclass of the
GKRule class (which represents rules to be used by
GKRule objects). Custom subclasses of
GKNSPredicate use an
NSPredicate object to evaluate a rule, rather than requiring custom logic for evaluation as is the case with custom
GameplayKit evaluates rules in the context of a
GKRule object, so custom rule classes should be functional—that is, they generally should not carry independent state that affects their predicate or action.
Methods to Override
perform method to perform whatever actions should result when your rule is satisfied (that is, when its
predicate property evaluates to true in the context of the provided rule system).
Alternatives to Subclassing
asserting Fact: grade:)
init(predicate:to create a rule that uses an
retracting Fact: grade:)
NSPredicateobject for evaluation and whose action asserts or retracts a fact in the containing rule system.