Contents

GKNSPredicateRule

A rule for use in a rule system that uses a Foundation Nspredicate object to evaluate itself.

Declaration

class GKNSPredicateRule

Overview

The GKNSPredicateRule class is a specialized subclass of the GKRule class (which represents rules to be used by GKRuleSystem objects). Custom subclasses of GKNSPredicateRule use an NSPredicate object to evaluate a rule, rather than requiring custom logic for evaluation as is the case with custom GKRule subclasses.

For more information about rules and rule systems, read Rule Systems in GameplayKit Programming Guide.

Subclassing Notes

GameplayKit evaluates rules in the context of a GKRuleSystem 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

Override the performAction(in:) 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

Topics

Creating a Predicate-Based Rule

Evaluating a Rule

See Also

Rule Systems