<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFTypeRef",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@T@CFTypeRef"
  },
  "title" : "CFTypeRef"
}
-->

# CFTypeRef

An untyped “generic” reference to any Core Foundation object.

```
typealias CFTypeRef = AnyObject
```

## Discussion

All other Core Foundation opaque types derive from `CFTypeRef`. The functions, callbacks, data types, and constants defined for CFType can be used by any derived opaque type. Hence, `CFTypeRef` functions are referred to as “polymorphic functions.” You use `CFTypeRef` functions to retain and release objects, to compare and inspect objects, get descriptions of objects and opaque types, and to get object allocators.

## Topics

### Memory Management

[`CFGetAllocator`](/documentation/CoreFoundation/CFGetAllocator(_:))

Returns the allocator used to allocate a Core Foundation object.

[`CFGetRetainCount`](/documentation/CoreFoundation/CFGetRetainCount(_:))

Returns the reference count of a Core Foundation object.

[`CFMakeCollectable`](/documentation/CoreFoundation/CFMakeCollectable)

Makes a newly-allocated Core Foundation object eligible for garbage collection.

[`CFRelease`](/documentation/CoreFoundation/CFRelease)

Releases a Core Foundation object.

[`CFRetain`](/documentation/CoreFoundation/CFRetain)

Retains a Core Foundation object.

### Determining Equality

[`CFEqual`](/documentation/CoreFoundation/CFEqual(_:_:))

Determines whether two Core Foundation objects are considered equal.

### Hashing

[`CFHash`](/documentation/CoreFoundation/CFHash(_:))

Returns a code that can be used to identify an object in a hashing structure.

### Miscellaneous Functions

[`CFCopyDescription`](/documentation/CoreFoundation/CFCopyDescription(_:))

Returns a textual description of a Core Foundation object.

[`CFCopyTypeIDDescription`](/documentation/CoreFoundation/CFCopyTypeIDDescription(_:))

Returns a textual description of a Core Foundation type, as identified by its type ID, which can be used when debugging.

[`CFGetTypeID`](/documentation/CoreFoundation/CFGetTypeID(_:))

Returns the unique identifier of an opaque type to which a Core Foundation object belongs.

[`CFShow`](/documentation/CoreFoundation/CFShow(_:))

Prints a description of a Core Foundation object to stderr.

### Data Types

[`CFHashCode`](/documentation/CoreFoundation/CFHashCode)

A type for hash codes returned by the `CFHash` function.

[`CFTypeID`](/documentation/CoreFoundation/CFTypeID)

A type for unique, constant integer values that identify particular Core Foundation opaque types.

## See Also

  [Memory Management Programming Guide for Core Foundation](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/CFMemoryMgmt.html#//apple_ref/doc/uid/10000127i)

  [Core Foundation Design Concepts](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFDesignConcepts/CFDesignConcepts.html#//apple_ref/doc/uid/10000122i)



---

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)