Core Foundation provides several polymorphic functions. These functions can take any Core Foundation object as a parameter and (in one instance, CFRetain
) can return any Core Foundation object. These parameters and return values are given the type of CFTypeRef
, a generic object-reference type. CFType is analogous to a root class in object-oriented languages because its functions can be reused by all other objects.
You use polymorphic functions for operations that are common to all Core Foundation objects:
Reference counting.
CFType provides several polymorphic functions for manipulating and obtaining the reference count of objects. See “Memory Management” for more about these functions.
Comparing objects.
The CFEqual
function compares any two Core Foundation objects (see “Comparing Objects”). The basis of equality depends on the type of objects compared. For example, if both are CFString objects the test involves a character-by-character comparison.
Hashing objects.
The CFHash
function returns a unique hash code identifying a Core Foundation object (see “Comparing Objects”). You can use the hash code as a table address in a hash table structure. If two objects are equal (as determined by the CFEqual
function), they must have the same hash value.
Inspecting objects.
CFType gives you the means to inspect objects and thereby learn about their contents and the type to which they “belong.” The CFCopyDescription
function returns a string (more precisely, a reference to a CFString object) that describes an object. The CFCopyTypeIDDescription
function, which takes a CFTypeID
rather than a CFTypeRef
parameter, returns a string reference that describes the opaque type identified by the type ID. These functions are primarily intended to assist debugging; see “Inspecting Objects” for more on these functions.
You can also determine the opaque type to which a generically typed object belongs by getting its type ID with the CFGetTypeID
function and then comparing that value with known type IDs. See “Inspecting Objects” for more on this task.
© 2003, 2005 Apple Computer, Inc. All Rights Reserved. (Last updated: 2005-08-11)