<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTableViewDelegate/tableView(_:viewFor:row:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTableViewDelegate(im)tableView:viewForTableColumn:row:"
  },
  "title" : "tableView(_:viewFor:row:)"
}
-->

# tableView(_:viewFor:row:)

Asks the delegate for a view to display the specified row and column.

```
@MainActor optional func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView?
```

## Parameters

`tableView`

The table view that sent the message.

`tableColumn`

The table column. (If the row is a group row, `tableColumn` is `nil`.)

`row`

The row index.

## Return Value

The view to display the specified column and row. If you return `nil`, a view will not be shown at that location.

## Discussion

This method is required if you want to use [`NSView`](/documentation/AppKit/NSView) objects instead of [`NSCell`](/documentation/AppKit/NSCell) objects for the cells within a table view. Cells and views can’t be mixed within the same table view.

It’s recommended that the implementation of this method first call the [`NSTableView`](/documentation/AppKit/NSTableView) method [`makeView(withIdentifier:owner:)`](/documentation/AppKit/NSTableView/makeView(withIdentifier:owner:)) passing, respectively, the `tableColumn` parameter’s identifier and `self` as the owner to attempt to reuse a view that is no longer visible or automatically unarchive an associated prototype view for that identifier. The `frame` of the view returned by this method is not important, and it will be automatically set by the table.

The view’s properties should be properly set up before returning the result.

When using Cocoa bindings, this method is optional if at least one identifier has been associated with the table view at design time. (Note that a view’s identifier must be the same as the identifier of its column. An easy way to achieve this is to use the Automatic identifier setting in Interface Builder.) If this method isn’t implemented, the table will automatically call the [`NSTableView`](/documentation/AppKit/NSTableView) method [`makeView(withIdentifier:owner:)`](/documentation/AppKit/NSTableView/makeView(withIdentifier:owner:)) with the `tableColumn` parameter’s identifier and the table view’s `delegate` as parameters, to attempt to reuse a previous view, or automatically unarchive a prototype associated with the table view. If this method is implemented, you can set up properties that aren’t using bindings.

The autoresizing mask of the returned view will automatically be set to [`height`](/documentation/AppKit/NSView/AutoresizingMask-swift.struct/height) to resize properly on row height changes.

## See Also

[Table View](/documentation/AppKit/table-view)

Display custom data in rows and columns.

[Drag and Drop](/documentation/AppKit/drag-and-drop)

Support the direct manipulation of your app’s content using drag and drop.



---

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)