<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSRuleEditor/insertRow(at:with:asSubrowOfRow:animate:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSRuleEditor(im)insertRowAtIndex:withType:asSubrowOfRow:animate:"
  },
  "title" : "insertRow(at:with:asSubrowOfRow:animate:)"
}
-->

# insertRow(at:with:asSubrowOfRow:animate:)

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

```
func insertRow(at rowIndex: Int, with rowType: NSRuleEditor.RowType, asSubrowOfRow parentRow: Int, animate shouldAnimate: Bool)
```

## Parameters

`rowIndex`

The index at which the new row should be inserted. `rowIndex` must be greater than `parentRow`, and much specify a row that does not fall amongst the children of some other parent.

`rowType`

The type of the new row.

`parentRow`

The index of the row of which the new row is a child. Pass `-1` to indicate that the new row should be a root row.

`shouldAnimate`

<doc://com.apple.documentation/documentation/Swift/true> if creation of the new row should be animated, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

> Important:
> If `parentRow` is greater than or equal to `rowIndex`, or if `rowIndex` would fall amongst the children of some other parent, or if the nesting mode forbids this configuration, an `NSInvalidArgumentException` is raised.

---

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)