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

# CFTreeSetContext(_:_:)

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

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

## Parameters

`tree`

The tree to modify.

`context`

The [`CFTreeContext`](/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 [`CFTreeContext`](/documentation/CoreFoundation/CFTreeContext) structure-sized block of storage, the result is undefined. If the version number of the storage is not a valid [`CFTreeContext`](/documentation/CoreFoundation/CFTreeContext) version number, the result is undefined.

## Discussion

---

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)