Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

About Property Lists

This section explains what property lists are and when you should use them.

Contents:

What is a Property List?
When to Use Property Lists
Property List Representations


What is a Property List?

A property list is a data representation used by Cocoa and Core Foundation as a convenient way to store, organize, and access standard object types. Frequently called a “plist,” a property list is an object of one of several certain Cocoa or Core Foundation types, including arrays, dictionaries, strings, binary data, numbers, dates, and Boolean values. Conceptually, therefore, you can think of “property list” as being an abstract superclass of all these classes. If you receive a property list object, you know that it must be an instance of one of these types, but a priori you may not know which.

If a property list object is a container (an array or dictionary), all objects contained within it must also be supported property list objects. (Arrays and dictionaries can contain objects not supported by the architecture, but are then not property lists, and cannot be saved and restored with the various property list methods.) Moreover, although dictionary keys in NSDictionary and CFDictionary are defined to be an object of any type, for property lists they must be string objects.

Cocoa property lists organize data into named values and lists of values using these classes:

The property list format supports all built-in subclasses of java.lang.Number except for BigInteger: Byte, Double, Float, Integer, Long, and Short.

The Core Foundation property list API, defined in <CoreServices/CoreServices.h>, supports the following Core Foundation types:

Because all these types can be automatically cast to and from their corresponding Cocoa types, you can use the Core Foundation property list API with Cocoa objects. In most cases, however, methods provided by the NSPropertyListSerialization class should provide enough flexibility.

When to Use Property Lists

Many applications require a mechanism for storing information that will be needed at a later time. For situations where you need to store small amounts of persistent data, less than a few hundred kilobytes, property lists offer a uniform and convenient means of organizing, storing, and accessing the data.

In some situations, the property list architecture may prove insufficient. If you need a way to store large, complex graphs of objects, objects not supported by the property list architecture, or objects whose mutability settings must be retained, use archiving. See Archives and Serializations for more information.

If you are looking for a way to implement user or application preferences, Cocoa provides a class specifically for this purpose. While the user defaults system does use property lists to store information, you do not have to access these plists directly. See User Defaults for more information.

Property List Representations

A property list can be stored in one of three different ways: in an XML representation, or in an “old-style” ASCII format inherited from OpenStep, or in a binary format. In general, the XML format is preferred over the other two.

All of the property list types can be serialized in all three formats. However, number and date objects stored in an old-style ASCII plist will be restored as strings.

“XML Property Lists,” “Old-Style ASCII Property Lists,” and “Binary Property Lists” describe these three formats and when to use them.



< Previous PageNext Page > Hide TOC


Last updated: 2006-11-07




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.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice