Important: The information in this document is obsolete and should not be used for new development.
Inherits from | |
Package | com.apple.cocoa.foundation |
Companion guides |
The NSPropertyListSerialization class provides methods that convert property list objects to and from several serialized formats. Property list objects include NSData, NSString, NSArray, NSDictionary, NSDate, and number objects.
Creates a new NSPropertyListSerialization object.
public NSPropertyListSerialization
()
All the NSPropertyListSerialization methods are static, so there is no need to create instances of NSPropertyListSerialization.
Creates a data object, serializes aPropertyList into it, and returns the data object.
public static NSData dataFromPropertyList
(Object aPropertyList)
aPropertyList must be a kind of NSData, string, NSArray, or NSDictionary. Container objects must also contain only these kinds of objects.
Returns an NSData object in the property list format specified by plist or null
if plist does not represent a valid property list.
public static NSData dataFromPropertyList
(Object plist, int format, String[] errorString)
plist must be a kind of NSData, string, number, NSDate, NSArray, or NSDictionary. Container objects must also contain only these kinds of objects. On return, if the conversion is successful, errorString is null
. If the conversion fails, errorString points to a string describing the nature of the error. Possible values for format are described in “Constants.”
Returns a property list object corresponding to the representation in serialization or null
if serialization does not represent a property list.
public static Object propertyListFromData
(NSData serialization)
If the property list object is a dictionary or an array, the recomposed object is made immutable.
Returns a property list object corresponding to the representation in data, or null
if data does not represent a valid property list in a supported format.
public static Object propertyListFromData
(NSData data, int opt, int[] format, String[] errorString)
The mutability option opt determines whether the property list’s containers and/or leaves are mutable. If the property list is valid, the format is returned in the first element of the array format. Possible values for opt and format are described in “Constants.”
Returns a property list object corresponding to the representation in serialization or null
if serialization does not represent a property list.
public static Object propertyListFromString
(String serialization)
If the property list object is a dictionary or an array, the recomposed object is made immutable. This method can parse both XML and non-XML style property list strings.
Returns a property list object corresponding to the XML representation in serialization or null
if serialization does not represent a property list.
public static Object propertyListFromXMLData
(NSData serialization)
If the property list object is a dictionary or an array, the recomposed object is made immutable.
Returns true
if plist is a valid property list in format format, false
otherwise.
public static boolean propertyListIsValidForFormat
(Object plist, int format)
Possible values for format are listed in “Constants.”
Creates an old-style string representation (non-XML) of aPropertyList.
public static String stringFromPropertyList
(Object aPropertyList)
aPropertyList must be a kind of NSData, NSString, NSDate, number class, NSArray, or NSDictionary. Container objects must also contain only these same kinds of objects. When read back by propertyListFromString
, NSDate and numerical values are interpreted as strings.
Creates a data object, serializes aPropertyList into it in XML format, and returns the data object.
public static NSData XMLDataFromPropertyList
(Object aPropertyList)
aPropertyList must be a kind of NSData, string, NSDate, number, NSArray, or NSDictionary. Container objects must also contain only these same kinds of objects.
Note that XML can handle more data types than the binary serialization created by dataFromPropertyList
.
The following table describes the constants used to specify mutability options in property lists:
The following table describes the constants used to specify property list serialization format:
© 1997, 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-07-24)