<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSRuleEditor",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSRuleEditor"
  },
  "title" : "NSRuleEditor"
}
-->

# NSRuleEditor

An interface for configuring a rule-based list of options.

```
class NSRuleEditor
```

## Overview

A rule editor lets the user visually create and configure a list of options that are expressed as a predicate. (For more information, see <doc://com.apple.documentation/documentation/Foundation/NSPredicate>.) Each row displayed by the rule editor represents a particular path down a tree of choices. The rule editor’s delegate provides the tree of choices to be displayed. The rule editor presents those choices to the user as a row of popup buttons, static text fields, and custom views.

`NSRuleEditor` exposes one binding, `rows`. You can bind `rows` to an ordered collection (such as an instance of `NSMutableArray`). Each object in the collection should have the following properties:

- @“rowType”: An integer representing the type of the row (`NSRuleEditorRowType`).
- @“subrows”: An ordered to-many relation (such as an instance of `NSMutableArray`) containing the directly nested subrows for the given row.
- @“displayValues”: An ordered to-many relation containing the display values for the row.
- @“criteria”: An ordered to-many relation containing the criteria for the row.

> Note: If you override ``doc://com.apple.appkit/documentation/AppKit/NSView/viewDidMoveToWindow()`` in a subclass of ``doc://com.apple.appkit/documentation/AppKit/NSRuleEditor``, you must invoke super’s implementation.

## Topics

### Configuring the Delegate

[`delegate`](/documentation/AppKit/NSRuleEditor/delegate)

The rule editor’s delegate.

[`NSRuleEditorDelegate`](/documentation/AppKit/NSRuleEditorDelegate)

The `NSRuleEditorDelegate` protocol defines the optional methods implemented by delegates of [`NSRuleEditor`](/documentation/AppKit/NSRuleEditor) objects.

### Configuring a Rule Editor

[`isEditable`](/documentation/AppKit/NSRuleEditor/isEditable)

A Boolean value that determines whether the rule editor is editable.

[`nestingMode`](/documentation/AppKit/NSRuleEditor/nestingMode-swift.property)

The rule editor’s nesting mode.

[`NSRuleEditor.NestingMode`](/documentation/AppKit/NSRuleEditor/NestingMode-swift.enum)

Specifies a type for nesting modes.

[`canRemoveAllRows`](/documentation/AppKit/NSRuleEditor/canRemoveAllRows)

A Boolean value that indicates whether all the rows can be removed.

[`rowHeight`](/documentation/AppKit/NSRuleEditor/rowHeight)

The rule editor’s row height.

### Working with Formatting

[`formattingDictionary`](/documentation/AppKit/NSRuleEditor/formattingDictionary)

The formatting dictionary for the rule editor.

[`formattingStringsFilename`](/documentation/AppKit/NSRuleEditor/formattingStringsFilename)

The name of the rule editor’s strings file.

### Providing Data

[`reloadCriteria()`](/documentation/AppKit/NSRuleEditor/reloadCriteria())

Instructs the receiver to refetch criteria from its delegate.

[`setCriteria(_:andDisplayValues:forRowAt:)`](/documentation/AppKit/NSRuleEditor/setCriteria(_:andDisplayValues:forRowAt:))

Modifies the row at a given index to contain the given items and values.

[`criteria(forRow:)`](/documentation/AppKit/NSRuleEditor/criteria(forRow:))

Returns the currently chosen items for a given row.

[`displayValues(forRow:)`](/documentation/AppKit/NSRuleEditor/displayValues(forRow:))

Returns the chosen values for a given row.

### Obtaining Row Information

[`numberOfRows`](/documentation/AppKit/NSRuleEditor/numberOfRows)

The number of rows in the rule editor.

[`parentRow(forRow:)`](/documentation/AppKit/NSRuleEditor/parentRow(forRow:))

Returns the index of the parent of a given row.

[`row(forDisplayValue:)`](/documentation/AppKit/NSRuleEditor/row(forDisplayValue:))

Returns the index of the row containing a given value.

[`rowType(forRow:)`](/documentation/AppKit/NSRuleEditor/rowType(forRow:))

Returns the type of a given row.

[`NSRuleEditor.RowType`](/documentation/AppKit/NSRuleEditor/RowType)

Specifies a type for row types.

[`subrowIndexes(forRow:)`](/documentation/AppKit/NSRuleEditor/subrowIndexes(forRow:))

Returns the immediate subrows of a given row.

### Working with the Selection

[`selectedRowIndexes`](/documentation/AppKit/NSRuleEditor/selectedRowIndexes)

The indexes of the rule editor’s selected rows.

[`selectRowIndexes(_:byExtendingSelection:)`](/documentation/AppKit/NSRuleEditor/selectRowIndexes(_:byExtendingSelection:))

Sets in the receiver the indexes of rows that are selected.

### Manipulating Rows

[`addRow(_:)`](/documentation/AppKit/NSRuleEditor/addRow(_:))

Adds a row to the receiver.

[`insertRow(at:with:asSubrowOfRow:animate:)`](/documentation/AppKit/NSRuleEditor/insertRow(at:with:asSubrowOfRow:animate:))

Adds a new row of a given type at a given location.

[`removeRow(at:)`](/documentation/AppKit/NSRuleEditor/removeRow(at:))

Removes the row at a given index.

[`removeRows(at:includeSubrows:)`](/documentation/AppKit/NSRuleEditor/removeRows(at:includeSubrows:))

Removes the rows at given indexes.

### Working with Predicates

[`predicate`](/documentation/AppKit/NSRuleEditor/predicate)

The rule editor’s predicate.

[`reloadPredicate()`](/documentation/AppKit/NSRuleEditor/reloadPredicate())

Instructs the receiver to regenerate its predicate by invoking the corresponding delegate method.

[`predicate(forRow:)`](/documentation/AppKit/NSRuleEditor/predicate(forRow:))

Returns the predicate for a given row.

### Supporting Bindings

[`rowClass`](/documentation/AppKit/NSRuleEditor/rowClass)

The class used to create a new row in the “rows” binding.

[`rowTypeKeyPath`](/documentation/AppKit/NSRuleEditor/rowTypeKeyPath)

The key path for the row type.

[`subrowsKeyPath`](/documentation/AppKit/NSRuleEditor/subrowsKeyPath)

The key path for the subrows.

[`criteriaKeyPath`](/documentation/AppKit/NSRuleEditor/criteriaKeyPath)

The criteria key path.

[`displayValuesKeyPath`](/documentation/AppKit/NSRuleEditor/displayValuesKeyPath)

The display values key path.

### Notifications

[`rowsDidChangeNotification`](/documentation/AppKit/NSRuleEditor/rowsDidChangeNotification)

This notification is posted to the default notification center whenever the view’s rows change.



---

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)