Next Page > Hide TOC

Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

NSPropertyListSerialization

Inherits from
Package
com.apple.cocoa.foundation
Companion guides

Overview

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.

Tasks

Constructors

Serializing Property Lists

Testing Property Lists

Deserializing Property Lists

Constructors

NSPropertyListSerialization

Creates a new NSPropertyListSerialization object.

public NSPropertyListSerialization()

Discussion

All the NSPropertyListSerialization methods are static, so there is no need to create instances of NSPropertyListSerialization.

Availability

Static Methods

dataFromPropertyList

Creates a data object, serializes aPropertyList into it, and returns the data object.

public static NSData dataFromPropertyList(Object aPropertyList)

Discussion

aPropertyList must be a kind of NSData, string, NSArray, or NSDictionary. Container objects must also contain only these kinds of objects.

Availability
See Also

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)

Discussion

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.”

Availability
See Also

propertyListFromData

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)

Discussion

If the property list object is a dictionary or an array, the recomposed object is made immutable.

Availability
See Also

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)

Discussion

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.”

Availability
See Also

propertyListFromString

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)

Discussion

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.

See Also

propertyListFromXMLData

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)

Discussion

If the property list object is a dictionary or an array, the recomposed object is made immutable.

Availability
See Also

propertyListIsValidForFormat

Returns true if plist is a valid property list in format format, false otherwise.

public static boolean propertyListIsValidForFormat(Object plist, int format)

Discussion

Possible values for format are listed in “Constants.”

Availability

stringFromPropertyList

Creates an old-style string representation (non-XML) of aPropertyList.

public static String stringFromPropertyList(Object aPropertyList)

Discussion

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.

XMLDataFromPropertyList

Creates a data object, serializes aPropertyList into it in XML format, and returns the data object.

public static NSData XMLDataFromPropertyList(Object aPropertyList)

Discussion

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.

Availability
See Also

Constants

The following table describes the constants used to specify mutability options in property lists:

Constant

Description

PropertyListImmutable

Causes the returned property list to contain immutable objects.

PropertyListMutableContainers

Causes the returned property list to have mutable containers but immutable leaves.

PropertyListMutableContainersAndLeaves

Causes the returned property list to have mutable containers and leaves.

The following table describes the constants used to specify property list serialization format:

Constant

Description

PropertyListOpenStepFormat

Specifies the old-style ASCII property list format inherited from the OpenStep APIs.

PropertyListXMLFormat

Specifies the XML property list format.

PropertyListBinaryFormat

Specifies the binary property list format.



Next Page > Hide TOC


© 1997, 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-07-24)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.