---
title: "tableView(_:dataCellFor:row:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstableviewdelegate/tableview(_:datacellfor:row:)"
---

# tableView(_:dataCellFor:row:)

Asks the delegate for a custom data cell for the specified row and column.

## Declaration

```swift
@MainActor optional func tableView(_ tableView: NSTableView, dataCellFor tableColumn: NSTableColumn?, row: Int) -> NSCell?
```

## Parameters

- `tableView`: The table view that sent the message.
- `tableColumn`: The table column.
- `row`: The row index.

## Return Value

Return Value An NSCell subclass that is used for the specified row and tableColumn. The returned cell must properly implement copyWithZone:.

## Discussion

Discussion A different data cell can be returned for any particular table column and row, or a cell that will be used for the entire row (that is, a full width cell). If tableColumn is non-nil, you should return a cell (generally as the result of sending tableColumn a dataCell(forRow:) message). While each row is being drawn, this method is first called with a tableColumn value of nil to allow you to return a group cell—that is, a cell that will be used to draw the entire row. If you return a cell when tableColumn is nil, all implemented datasource and delegate methods must be prepared to handle a nil table column value. If you don’t return a cell, this method is called once for each tableColumn in tableView. note: This method is only valid for NSCell-based table views.

## See Also

### Providing cells for rows and columns

- [tableView(_:willDisplayCell:for:row:)](appkit/nstableviewdelegate/tableview(_:willdisplaycell:for:row:).md)
- [tableView(_:shouldShowCellExpansionFor:row:)](appkit/nstableviewdelegate/tableview(_:shouldshowcellexpansionfor:row:).md)
- [tableView(_:toolTipFor:rect:tableColumn:row:mouseLocation:)](appkit/nstableviewdelegate/tableview(_:tooltipfor:rect:tablecolumn:row:mouselocation:).md)
