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

# CFTreeSetContext(_:_:)

Replaces the context of a tree by releasing the old information pointer and retaining the new one.

## Declaration

```swift
func CFTreeSetContext(_ tree: CFTree!, _ context: UnsafePointer<CFTreeContext>!)
```

## Parameters

- `tree`: The tree to modify.
- `context`: The doc://com.apple.corefoundation/documentation/CoreFoundation/CFTreeContext structure to be copied and used as the context of the new tree. The information pointer will be retained by the tree if a retain function is provided. If this value is not a valid C pointer to a doc://com.apple.corefoundation/documentation/CoreFoundation/CFTreeContext structure-sized block of storage, the result is undefined. If the version number of the storage is not a valid doc://com.apple.corefoundation/documentation/CoreFoundation/CFTreeContext version number, the result is undefined.

## See Also

### Modifying a Tree

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