Class

NSRuleEditor

An NSRuleEditor object is a view that allows the user to visually create and configure a list of options which are expressed by the rule editor as a predicate (see Predicate Programming Guide). The view has a delegate which offers a tree of choices to the view. The choices are presented by the view to the user as a row of popup buttons, static text fields, and custom views. Each row in the list represents a particular path down the tree of choices.

Overview

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.

Symbols

Configuring a Rule Editor

var delegate: NSRuleEditorDelegate?

The rule editor’s delegate.

var isEditable: Bool

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

var nestingMode: NSRuleEditorNestingMode

The rule editor’s nesting mode.

var canRemoveAllRows: Bool

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

var rowHeight: CGFloat

The rule editor’s row height.

Working with Formatting

var formattingDictionary: [String : String]?

The formatting dictionary for the rule editor.

var formattingStringsFilename: String?

The name of the rule editor’s strings file.

Providing Data

func reloadCriteria()

Instructs the receiver to refetch criteria from its delegate.

func setCriteria([Any], andDisplayValues: [Any], forRowAt: Int)

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

func criteria(forRow: Int)

Returns the currently chosen items for a given row.

func displayValues(forRow: Int)

Returns the chosen values for a given row.

Obtaining Row Information

var numberOfRows: Int

The number of rows in the rule editor.

func parentRow(forRow: Int)

Returns the index of the parent of a given row.

func row(forDisplayValue: Any)

Returns the index of the row containing a given value.

func rowType(forRow: Int)

Returns the type of a given row.

func subrowIndexes(forRow: Int)

Returns the immediate subrows of a given row.

Working with the Selection

var selectedRowIndexes: IndexSet

The indexes of the rule editor’s selected rows.

func selectRowIndexes(IndexSet, byExtendingSelection: Bool)

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

Manipulating Rows

func addRow(Any?)

Adds a row to the receiver.

func removeRow(at: Int)

Removes the row at a given index.

func removeRows(at: IndexSet, includeSubrows: Bool)

Removes the rows at given indexes.

Working with Predicates

var predicate: NSPredicate?

The rule editor’s predicate.

func reloadPredicate()

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

func predicate(forRow: Int)

Returns the predicate for a given row.

Supporting Bindings

var rowClass: AnyClass

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

var rowTypeKeyPath: String

The key path for the row type.

var subrowsKeyPath: String

The key path for the subrows.

var criteriaKeyPath: String

The criteria key path.

var displayValuesKeyPath: String

The display values key path.

Constants

NSRuleEditorNestingMode

Specifies a type for nesting modes.

Nesting Modes

These constants specify the nesting mode for the rule editor.

NSRuleEditorRowType

Specifies a type for row types.

Row Types

Specify the type of a rule editor row.

Predicate Part Keys

These strings are used as keys to the dictionary returned from the delegate’s ruleEditor(_:predicatePartsForCriterion:withDisplayValue:inRow:) optional method. To construct a valid predicate, the union of the dictionaries for each item in the row must contain the required parts.

Notifications

static let NSRuleEditorRowsDidChange: NSNotification.Name

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

Relationships

Inherits From

Conforms To