---
title: "init(blockPredicate:action:)"
framework: gameplaykit
role: symbol
role_heading: Initializer
path: "gameplaykit/gkrule/init(blockpredicate:action:)"
---

# init(blockPredicate:action:)

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

## Declaration

```swift
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:

## Return Value

Return Value A new rule object.

## Discussion

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 NSKeyedArchiver class. For archivable rules, use the GKRule methods listed in Creating Data-Driven Rules.
