<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFTreeInsertSibling(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFTreeInsertSibling"
  },
  "title" : "CFTreeInsertSibling(_:_:)"
}
-->

# CFTreeInsertSibling(_:_:)

Inserts a new sibling after a given tree.

```
func CFTreeInsertSibling(_ tree: CFTree!, _ newSibling: CFTree!)
```

## Parameters

`tree`

The tree after which to insert `newSibling`. `tree` must have a parent.

`newSibling`

The sibling to add. `newSibling` must not have a parent.

## Discussion

When a child tree is added to another tree, the child tree is retained by its new parent.

If you want to manipulate an existing tree structure, since `newSibling` must not have a parent you need to remove a tree from its parent in order to move it to a new position. If you do this, you should retain the tree before you actually remove it from its parent (see [`CFTreeRemove(_:)`](/documentation/CoreFoundation/CFTreeRemove(_:))).

---

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)