- iOS 2.0+
- macOS 10.0+
- tvOS 9.0+
- watchOS 2.0+
CFPropertyList provides functions that convert property list objects to and from several serialized formats such as XML. The
CFProperty type that denotes CFPropertyList objects is an abstract type for property list objects. Depending on the contents of the XML data used to create the property list,
CFProperty can be any of the property list objects: CFData, CFString, CFArray, CFDictionary, CFDate, CFBoolean, and CFNumber. Note that if you use a property list to generate XML, the keys of any dictionaries in the property list must be CFString objects.
It is important to understand that CFPropertyList provides an abstraction for all the property list types—you can think of CFPropertyList in object-oriented terms as being the superclass of CFString, CFNumber, CFDictionary, and so on. When a Core Foundation function returns a
CFProperty, it means that the value may be any of the property list types. For example,
CFPreferences returns a
CFProperty. This means that the value returned can be a CFString object, a CFNumber object, a CFDictionary object, and so on again. You can use
CFGet to determine what type of object a property list value is.
You use one of the
CFProperty functions to create a property list object given an existing property list object, raw XML data (as in a file), or a stream. You can also convert a property list object to XML using the
CFProperty function. You use the
CFProperty function to write a property list to an output stream, and validate a property list object using the
CFProperty function. CFPropertyList properly takes care of endian issues—a property list (whether represented by a stream, XML, or a CFData object) created on a PowerPC-based Macintosh is correctly interpreted on an Intel-based Macintosh, and vice versa.
For code examples illustrating how to read and write property list files, see Property List Programming Topics for Core Foundation and in particular Saving and Restoring Property Lists.