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

# outlineView(_:child:ofItem:)

Returns the child item at the specified index of a given item.

```
@MainActor optional func outlineView(_ outlineView: NSOutlineView, child index: Int, ofItem item: Any?) -> Any
```

## Parameters

`outlineView`

The outline view that sent the message.

`index`

The index of the child item from `item` to return.

`item`

An item in the data source.

## Return Value

The child item at `index` of `item`. If `item` is `nil`, returns the appropriate child item of the root object.

## Discussion

Children of a given parent `item` are accessed sequentially. In order for the collapsed state of the outline view to remain consistent when it is reloaded you must always return the same object for a specified `child` and `item`.

> Important:
> While this method is marked as `@optional` in the protocol, **you must implement this method if you are not providing the data for the outline view using Cocoa bindings.**
> 
> Do not call ``doc://com.apple.appkit/documentation/AppKit/NSTableView/reloadData()`` from this method.

### Special Considerations

The [`outlineView(_:child:ofItem:)`](/documentation/AppKit/NSOutlineViewDataSource/outlineView(_:child:ofItem:)) method is called very frequently, so it must be efficient.

## See Also

[`outlineView(_:numberOfChildrenOfItem:)`](/documentation/AppKit/NSOutlineViewDataSource/outlineView(_:numberOfChildrenOfItem:))

Returns the number of child items encompassed by a given item.

[Outline View](/documentation/AppKit/outline-view)

Display a list-based interface for hierarchical data, where each level of hierarchy is indented from the previous one.



---

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)