<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSOutlineView/moveItem(at:inParent:to:inParent:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOutlineView(im)moveItemAtIndex:inParent:toIndex:inParent:"
  },
  "title" : "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.

```
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

This method parallels the [`moveRow(at:to:)`](/documentation/AppKit/NSTableView/moveRow(at:to:)) method of [`NSTableView`](/documentation/AppKit/NSTableView). The `newParent` can be the same as `oldParent` to reorder an item within the same parent.

> Note:
> ``doc://com.apple.appkit/documentation/AppKit/NSCell``-based outline views must first call ``doc://com.apple.appkit/documentation/AppKit/NSTableView/beginUpdates()`` before calling this method.

You can call this method multiple times within the same [`beginUpdates()`](/documentation/AppKit/NSTableView/beginUpdates())/[`endUpdates()`](/documentation/AppKit/NSTableView/endUpdates()) block. Moving from an invalid index, or to an invalid index, throws an exception.

---

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)