Initializes a rule with the specified predicate.
- iOS 9.0+
- macOS 10.11+
- Mac Catalyst 13.0+
- tvOS 9.0+
A predicate to be tested when evaluating the rule.
A new predicate-based rule object.
Rules based on
NSPredicate objects typically test information in the
state dictionary of the rule system evaluating the rule. For example, the following code creates a rule you might use to determine whether an enemy character in a game behaves aggressively.
This example presumes the rule system’s state dictionary contains an object for the key
player, which in turn exposes a numeric value for the key
GKNSPredicate class by itself does nothing in its
perform method—to create actions for predicate-based rules, you must subclass