PATH Documentation > WebObjects

Table of Contents

NSPropertyListSerialization


Inherits from:
Object
Package:
com.webobjects.foundation


Class Description


This class provides static methods that convert between property lists and their string representations, which can be either strings or NSData objects. A property list is a structure that represents organized data. It can be built from a combination of NSArrays, NSDictionaries, Strings, and NSData objects.

The string representation can be in XML or the ASCII plist format. To distinguish between the two formats, the parser that converts strings to property lists checks if the string starts with <?xml. A discussion of the ASCII plist format, A Primer on ASCII Property Lists, is available in the Mac OS X section of the Apple Developer Connection website. A discussion of XML property lists, Property List Services, is also available in the same area of the Apple Developer Connection website.

Some methods do not support XML property list representations, specifically booleanForString and intForString.

The NSPropertyListSerialization class cannot be instantiated.




Method Types


Extracting typed data
arrayForString
booleanForString
dictionaryForString
intForString
Converting to property lists
propertyListFromData
propertyListFromString
Converting from property lists
dataFromPropertyList
stringFromPropertyList


Static Methods



arrayForString

public static NSArray arrayForString(String string)

Parses the property list representation string and returns the resulting property list as an NSArray. If the root object is not an array, this method throws a ClassCastException.

See Also: dictionaryForString.



booleanForString

public static boolean booleanForString(String string)

Returns a boolean based on string according to the following table:
string's value Value returned
"YES" true
"true" true
Any other value false

The tests for "YES" and "true" are case insensitive.



dataFromPropertyList

public static NSData dataFromPropertyList( Object object, String encoding)

public static NSData dataFromPropertyList(Object object)

Converts the property list object into a string and returns it as a NSData object. The encoding parameter specifies the encoding used to convert the characters in the result string to byte. The one-argument version of the method uses the platform's default character encoding.

See Also: stringFromPropertyList



dictionaryForString

public static NSDictionary dictionaryForString(String string)

Parses the property list representation string and returns the resulting property list as an NSDictionary. If the root object is not a dictionary, this method throws a ClassCastException.

See Also: arrayForString.



intForString

public static int intForString(String string)

Parses string and returns the corresponding integer. If string is null, returns zero.

propertyListFromData

public static Object propertyListFromData( NSData data, String encoding)

public static Object propertyListFromData(NSData data)

Returns a property list converted from the byte array representation in data. The encoding parameter specifies the encoding used to convert the bytes in the data byte array to characters in a string representation. The one-argument version of the method uses the platform's default character encoding.

See Also: propertyListFromString



propertyListFromString

public static Object propertyListFromString(String string)

Returns a property list converted from the string representation string.

stringFromPropertyList

public static String stringFromPropertyList(Object object)

Converts the property list object into a string and returns it.

© 2001 Apple Computer, Inc. (Last Published April 17, 2001)


Table of Contents