<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKRule/init(blockPredicate:action:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKRule(cm)ruleWithBlockPredicate:action:"
  },
  "title" : "init(blockPredicate:action:)"
}
-->

# init(blockPredicate:action:)

Creates a rule whose predicate is evaluated and action is executed through the specified blocks.

```
convenience init(blockPredicate predicate: @escaping (GKRuleSystem) -> Bool, action: @escaping (GKRuleSystem) -> Void)
```

## Parameters

`action`

A block to be invoked after the rule’s predicate is satisfied. The block takes a single parameter:

- system: The rule system in whose context the rule is executing its action.

## Return Value

A new rule object.

## Discussion

Rules created using this method can run arbitrary code in their predicate and action, but do not encode their predicate or action when archiving with the <doc://com.apple.documentation/documentation/Foundation/NSKeyedArchiver> class. For archivable rules, use the [`GKRule`](/documentation/GameplayKit/GKRule) methods listed in Creating Data-Driven Rules.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)