<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTableView/moveRow(at:to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTableView(im)moveRowAtIndex:toIndex:"
  },
  "title" : "moveRow(at:to:)"
}
-->

# moveRow(at:to:)

Moves the specified row to the new row location using animation.

```
func moveRow(at oldIndex: Int, to newIndex: Int)
```

## Parameters

`oldIndex`

Initial row index.

`newIndex`

New row index.

## Discussion

This is similar to removing a row at `oldIndex` and inserting it at `newIndex`, except the same view is used and simply has its position updated to the new location.

Changes happen incrementally as they are sent to the table, so as soon as this method is called the row can be considered moved. However the underlying view is not moved until [`endUpdates()`](/documentation/AppKit/NSTableView/endUpdates()) has been called.

This method can be called multiple times within the same [`beginUpdates()`](/documentation/AppKit/NSTableView/beginUpdates()) and [`endUpdates()`](/documentation/AppKit/NSTableView/endUpdates()) block.

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

---

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)