<!--
{
  "availability" : [
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTreeNode",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTreeNode"
  },
  "title" : "NSTreeNode"
}
-->

# NSTreeNode

A node in a tree of nodes.

```
class NSTreeNode
```

## Overview

[`NSTreeNode`](/documentation/AppKit/NSTreeNode) simplifies the creation and management of trees of objects. Each tree node represents a model object. A tree node with `nil` as its parent node is considered the root of the tree.

## Topics

### Creating tree nodes

[`treeNodeWithRepresentedObject:`](/documentation/AppKit/NSTreeNode/treeNodeWithRepresentedObject:)

Creates and returns a tree node that represents the specified object.

[`init(representedObject:)`](/documentation/AppKit/NSTreeNode/init(representedObject:))

Initializes a newly allocated tree node that represents the specified object.

### Getting information about a node

[`representedObject`](/documentation/AppKit/NSTreeNode/representedObject)

The object the tree node represents.

[`indexPath`](/documentation/AppKit/NSTreeNode/indexPath)

The position of the receiver relative to its root parent.

[`isLeaf`](/documentation/AppKit/NSTreeNode/isLeaf)

A Boolean that indicates whether the receiver is a leaf node.

[`children`](/documentation/AppKit/NSTreeNode/children)

An array containing receiver’s child nodes.

[`mutableChildren`](/documentation/AppKit/NSTreeNode/mutableChildren)

A mutable array that provides read-write access to the receiver’s child nodes.

[`descendant(at:)`](/documentation/AppKit/NSTreeNode/descendant(at:))

Returns the receiver’s descendant at the specified index path.

[`parent`](/documentation/AppKit/NSTreeNode/parent)

The receiver’s parent node.

### Sorting the subtree

[`sort(with:recursively:)`](/documentation/AppKit/NSTreeNode/sort(with:recursively:))

Sorts the receiver’s subtree using the values of the represented objects with the specified sort descriptors.



---

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)