<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSOutlineView/expandItem(_:expandChildren:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOutlineView(im)expandItem:expandChildren:"
  },
  "title" : "expandItem(_:expandChildren:)"
}
-->

# expandItem(_:expandChildren:)

Expands a specified item and, optionally, its children.

```
func expandItem(_ item: Any?, expandChildren: Bool)
```

## Parameters

`item`

An item in the receiver.

    Starting in OS X version 10.5,  passing     `'nil'`     will expand each item under the root in the outline view.

`expandChildren`

If <doc://com.apple.documentation/documentation/Swift/true>, recursively expands `item` and its children. If <doc://com.apple.documentation/documentation/Swift/false>, expands `item` only (identical to [`expandItem(_:)`](/documentation/AppKit/NSOutlineView/expandItem(_:))).

## Discussion

For example, this method is invoked with the `expandChildren` parameter set to <doc://com.apple.documentation/documentation/Swift/true> when a user Option-clicks the disclosure triangle for an item in the outline view (to expand the item and all its contained items).

For each item expanded, posts an item expanded notification.

---

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)