---
title: "row(for:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstableview/row(for:)"
---

# row(for:)

Returns the index of the row for the specified view.

## Declaration

```swift
func row(for view: NSView) -> Int
```

## Parameters

- `view`: The view for which to retrieve the row.

## Return Value

Return Value The index of the row containing to view. This method returns -1 if the view is not in the table view. This method may also return -1 if the row containing the view is being animated away, such as during the deletion of a row.

## Discussion

Discussion This method is typically called in the action method for an NSButton (or NSControl) to find out what row (and column) the action should be performed on. The implementation is O(n) where n is the number of visible rows, so this method should generally not be called within a loop.

## See Also

### Updating the Table View Arrangement

- [beginUpdates()](appkit/nstableview/beginupdates().md)
- [endUpdates()](appkit/nstableview/endupdates().md)
- [moveRow(at:to:)](appkit/nstableview/moverow(at:to:).md)
- [insertRows(at:withAnimation:)](appkit/nstableview/insertrows(at:withanimation:).md)
- [removeRows(at:withAnimation:)](appkit/nstableview/removerows(at:withanimation:).md)
- [column(for:)](appkit/nstableview/column(for:).md)
