- iOS 2.0+
- macOS 10.0+
- tvOS 9.0+
- watchOS 2.0+
CFData and its derived mutable type, CFMutableData, provide support for data objects, object-oriented wrappers for byte buffers. Data objects let simple allocated buffers (that is, data with no embedded pointers) take on the behavior of Core Foundation objects. CFData creates static data objects, and CFMutableData creates dynamic data objects. Data objects are typically used for raw data storage.
You use the
CFData functions to create static data objects. These functions make a new copy of the supplied data. To create a data object that uses the supplied buffer instead of making a separate copy, use the
CFData function. You use the
CFData function to retrieve the bytes and the
CFData function to get the length of the bytes.
CFData is “toll-free bridged” with its Cocoa Foundation counterpart,
NSData. What this means is that the Core Foundation type is interchangeable in function or method calls with the bridged Foundation object. In other words, in a method where you see an
NSData * parameter, you can pass in a
CFData, and in a function where you see a
CFData parameter, you can pass in an
NSData instance. This also applies to concrete subclasses of
NSData. See Toll-Free Bridged Types for more information on toll-free bridging.