<!--
{
  "availability" : [
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSOutlineViewDelegate/outlineView(_:dataCellFor:item:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSOutlineViewDelegate(im)outlineView:dataCellForTableColumn:item:"
  },
  "title" : "outlineView(_:dataCellFor:item:)"
}
-->

# outlineView(_:dataCellFor:item:)

Returns the cell to use in a given column for a given item.

```
@MainActor optional func outlineView(_ outlineView: NSOutlineView, dataCellFor tableColumn: NSTableColumn?, item: Any) -> NSCell?
```

## Parameters

`outlineView`

The outline view that sent the message.

`tableColumn`

The table column that requires the cell. This value can be `nil`.

`item`

The item that requires the cell.

## Return Value

The cell to use in column `tableColumn` for item `item`, or `nil`. Because the outline view might copy the cell, the cell must properly implement <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/copyWithZone:>.

## Discussion

You can return a different data cell for any table column and item combination. Alternatively, you can return a full-width cell for the entire row.

If `tableColumn` is non-`nil`, you can return a cell. In most cases, however, you default to returning the result from [`tableView(_:dataCellFor:row:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:dataCellFor:row:)).

At the time of drawing, the outline view calls each row identified by `item` with a `nil` value for `tableColumn`. At this point, you can return a cell that the system can use to draw the entire row, acting as a group.

If you return a cell for the `nil` table column, prepare the other corresponding data source implementations and delegate methods to accept a `nil` value for `tableColumn`. If you don’t return a cell for the `nil` table column, the outline view calls this method once for each column, as usual.

---

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)