- iOS 2.0+
- macOS 10.0+
- tvOS 9.0+
- watchOS 2.0+
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
CFNumber, and in a function where you see a
CFNumber 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.