---
title: "CFTreeInsertSibling(_:_:)"
framework: Core Foundation
role: symbol
role_heading: Function
path: "corefoundation/cftreeinsertsibling(_:_:)"
---

# CFTreeInsertSibling(_:_:)

Inserts a new sibling after a given tree.

## Declaration

```swift
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

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(_:)).

## See Also

### Modifying a Tree

- [CFTreeAppendChild(_:_:)](corefoundation/cftreeappendchild(_:_:).md)
- [CFTreeRemoveAllChildren(_:)](corefoundation/cftreeremoveallchildren(_:).md)
- [CFTreePrependChild(_:_:)](corefoundation/cftreeprependchild(_:_:).md)
- [CFTreeRemove(_:)](corefoundation/cftreeremove(_:).md)
- [CFTreeSetContext(_:_:)](corefoundation/cftreesetcontext(_:_:).md)
