CFNumber

Overview

CFNumber encapsulates C scalar (numeric) types. It provides functions for setting and accessing the value as any basic C type. It also provides a compare function to determine the ordering of two CFNumber objects. CFNumber objects are used to wrap numerical values for use in Core Foundation property lists and collections.

CFNumber objects are not intended as a replacement for C scalar values and should not be used in APIs or implementations where scalar values are more appropriate and efficient.

CFNumber is “toll-free bridged” with its Cocoa Foundation counterpart, NSNumber. This means that the Core Foundation type is interchangeable in function or method calls with the bridged Foundation object. Therefore, in a method where you see an NSNumber * parameter, you can pass in a CFNumberRef, and in a function where you see a CFNumberRef parameter, you can pass in an NSNumber instance. This fact also applies to concrete subclasses of NSNumber. See Toll-Free Bridged Types for more information on toll-free bridging.

Symbols

Creating a Number

func CFNumberCreate(CFAllocator!, CFNumberType, UnsafeRawPointer!)

Creates a CFNumber object using a specified value.

Getting Information About Numbers

func CFNumberGetByteSize(CFNumber!)

Returns the number of bytes used by a CFNumber object to store its value.

func CFNumberGetType(CFNumber!)

Returns the type used by a CFNumber object to store its value.

func CFNumberGetValue(CFNumber!, CFNumberType, UnsafeMutableRawPointer!)

Obtains the value of a CFNumber object cast to a specified type.

func CFNumberIsFloatType(CFNumber!)

Determines whether a CFNumber object contains a value stored as one of the defined floating point types.

Comparing Numbers

func CFNumberCompare(CFNumber!, CFNumber!, UnsafeMutableRawPointer!)

Compares two CFNumber objects and returns a comparison result.

Getting the CFNumber Type ID

func CFNumberGetTypeID()

Returns the type identifier for the CFNumber opaque type.

Data Types

CFNumber

A reference to a CFNumber object.

Constants

CFNumberType

Flags used by CFNumber to indicate the data type of a value.

Predefined Values

CFNumber provides some predefined number values.