SponsorYour name here · $500/mo
Allof the following are true
Namecontains
Namecontainsreport
Namecontains
Anyof the following are true
Namecontains
Tagcontainsurgent
Namecontains
KindisPDF
Namecontains
CancelOK

The small − and + at the right end of each row remove that row or add one below itThe − and + at each row’s end remove or add a row

Rule Editor (Predicate Editor)

/ NSPredicateEditor · NSRuleEditor /

also called predicate editor, smart folder rules, smart mailbox conditions, query builder (web term)

“The rows of dropdowns with a − and + at the end” are a rule editor, AppKit's NSPredicateEditor. You see these rows in Finder's search and Smart Folders, Mail's Smart Mailboxes and Music's Smart Playlists: each row is one condition (what to check, how to compare, a value), − removes the row and + adds one below. A compound row (“All of the following are true”) groups the rows indented under it; in Music, holding Option turns + into a button that starts a group. It is not a stepper, the up and down pair on one number; Mail's Rules window uses the same rows for automations, and the web calls it a query builder.

If you called it…

“rows of dropdowns with a minus and plus button at the end of each row”“i can select several search criteria in pulldown menus and build a search via gui rather than by typing”“filter for choosing an attribute then choosing larger or smaller then choosing the value”“the plus button that adds another condition to my finder search”“the line that says all of the following are true, with indented rows under it”“the minus button at the end of a search condition row”

…you meant Rule Editor (Predicate Editor).

Anatomy — every part, named

  1. 1
    Compound row (All / Any of the following)NSRuleEditor.RowType.compound

    “All of the following are true” is a compound row: its pop-up switches the rows under it between All, Any and None.

  2. 2
    Add and remove buttons (− +)NSRuleEditor.addRow(_:)

    “The plus button” and the minus beside it sit at the right end of every row: + adds a row below this one and − removes this row (NSRuleEditor.removeRow(at:)).

  3. 3
    Criteria row (condition)NSPredicateEditorRowTemplate

    “Several search criteria in pulldown menus” are criteria rows: each one is a left pop-up for what to check, an operator pop-up such as “contains”, and a value.

  4. 4
    Nested rows (indented group)NSRuleEditor.NestingMode.compound

    “The rows pushed in under Any of the following” are a nested group: conditions that belong to the compound row above them, shifted right one step.

Prompt — paste into your agent

Add a rule editor, an NSPredicateEditor (an NSRuleEditor subclass; SwiftUI has none, so wrap it in NSViewRepresentable): one row per condition with a left pop-up, an operator pop-up and a value field, and a − and a + at the right end of every row that remove it or add one below. Describe the rows with NSPredicateEditorRowTemplate and read the result from objectValue. Never assemble the rows by hand from loose pop-up buttons.

Debug prompt — when it misbehaves

Paste this, then describe what you’re seeing — it hands your agent the classic failure modes to rule out first.

Debug my rule editor (NSPredicateEditor, NSRuleEditor, NSPredicateEditorRowTemplate). Rule out: a predicate that no row template matches, so the row stays blank and the console logs "unable to find template matching predicate"; no compound row template while the predicate uses AND or OR; a key path that is also a predicate keyword (size), which NSPredicate(format:) uppercases so nothing matches; nestingMode set to .single, which hides the − and + buttons; canRemoveAllRows false, so the last row's − stays dimmed; a rowHeight too small for the pop-ups; an operator or value type that doesn't fit the attribute; a plain NSRuleEditor with no delegate. The symptom:

In code

The exact names this thing goes by in code — each row is one framework’s word for it. Use the row that matches your project (or paste it into your prompt).

AppKitNSPredicateEditormacOS 10.5+; its rows come from an NSPredicate
AppKitNSRuleEditorthe base class; a delegate supplies the rows
AppKitNSPredicateEditorRowTemplatewhat one kind of row offers: its pop-ups and its value view
AppKitNSRuleEditor.NestingMode.compoundthe default; allows groups inside groups
SwiftUINSViewRepresentableno direct SwiftUI equivalent; wrap NSPredicateEditor
react-querybuilder<QueryBuilder>the web's version, called a query builder

See also

From the maker of this siteFowlNote · Notes that float over any app, one shortcut away