---
title: "moveItem(at:inParent:to:inParent:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsoutlineview/moveitem(at:inparent:to:inparent:)"
---

# moveItem(at:inParent:to:inParent:)

Moves an item at a given index in the given parent to a new index in a new parent.

## Declaration

```swift
func moveItem(at fromIndex: Int, inParent oldParent: Any?, to toIndex: Int, inParent newParent: Any?)
```

## Parameters

- `fromIndex`: Index of the item to be moved.
- `oldParent`: The parent of the item to be moved.
- `toIndex`: Index in the new parent to which the item is moved.
- `newParent`: The parent of the item after it is moved.

## Discussion

Discussion This method parallels the moveRow(at:to:) method of NSTableView. The newParent can be the same as oldParent to reorder an item within the same parent. 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. Moving from an invalid index, or to an invalid index, throws an exception.

## See Also

### Manipulating Items

- [insertItems(at:inParent:withAnimation:)](appkit/nsoutlineview/insertitems(at:inparent:withanimation:).md)
- [removeItems(at:inParent:withAnimation:)](appkit/nsoutlineview/removeitems(at:inparent:withanimation:).md)
