---
title: "insertItems(at:inParent:withAnimation:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsoutlineview/insertitems(at:inparent:withanimation:)"
---

# insertItems(at:inParent:withAnimation:)

Inserts new items at the given indexes in the given parent with the specified optional animations.

## Declaration

```swift
func insertItems(at indexes: IndexSet, inParent parent: Any?, withAnimation animationOptions: NSTableView.AnimationOptions = [])
```

## Parameters

- `indexes`: Indexes at which to insert items.
- `parent`: The parent for the items, or nil if the parent is the root.
- `animationOptions`: Animated slide effects used when inserting items.

## Discussion

Discussion This method parallels the insertRows(at:withAnimation:) method of NSTableView and is used in a way similar to the insert(_:at:) method of NSMutableArray. The method does nothing if parent is not expanded. The actual item values are determined by the data source’s outlineView(_:child:ofItem:) method (which is called only after endUpdates() to ensure data source integrity). note: NSCell-based outline views must first call beginUpdates() before calling this method. You can call this method multiple times within the same beginUpdates()/endUpdates() block; new insertions move previously inserted new items, just like modifying an array. Inserting an index beyond what is available throws an exception.

## See Also

### Manipulating Items

- [moveItem(at:inParent:to:inParent:)](appkit/nsoutlineview/moveitem(at:inparent:to:inparent:).md)
- [removeItems(at:inParent:withAnimation:)](appkit/nsoutlineview/removeitems(at:inparent:withanimation:).md)
