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:
CFType provides several polymorphic functions for manipulating and obtaining the reference count of objects. See Memory Management Programming Guide for Core Foundation for more about these functions.
CFEqualfunction 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.
CFHashfunction 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
CFEqualfunction), they must have the same hash value.
CFType gives you the means to inspect objects and thereby learn about their contents and the type to which they “belong.” The
CFCopyDescriptionfunction returns a string (more precisely, a reference to a CFString object) that describes an object. The
CFCopyTypeIDDescriptionfunction, which takes a
CFTypeIDrather than a
CFTypeRefparameter, 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
CFGetTypeIDfunction and then comparing that value with known type IDs. See Inspecting Objects for more on this task.