Polymorphic Functions
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 Programming Guide for Core Foundation 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 theCFEqual
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. TheCFCopyTypeIDDescription
function, which takes aCFTypeID
rather than aCFTypeRef
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.
Copyright © 2003, 2013 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2013-12-16