Base Services define a number of data types for general use in Core Foundation functions. The purpose of some of these types is to abstract primitive values that might have to change as the processor address space changes. The
CFIndex
type, for example, is used in index, count, length, and size parameters. The
CFOptionFlags
type is used for bitfield parameters and the
CFHashCode
type holds hashing results returned from the
CFHash
function and certain hashing callbacks.
Other base types are used in functions that take and return comparison and range values. CFRange is a structure that specifies any part of a linear sequence of items, from characters in a string to elements in a collection. For comparison functions, the
CFComparisonResult
type defines
enum
constants to represent appropriate return values (equal, less than, greater than). Some Core Foundation functions take callbacks to comparator functions; if you want a custom comparator, the function must conform to the signature specified by the
CFComparatorFunction
type.
ImportantThe integer value certain Core Foundation types, particularlyCFIndex
andCFTypeID
, can grow over time as the processor's address size grows. By using the base types for variables that interact with Core Foundation arguments of the same type, you will ensure a higher degree of source compatibility for your code.