O'Reilly logo

iPhone and iPad App 24-Hour Trainer by Gene Backlin, Abhishek Mishra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 22

Property Lists

iOS devices have the capability to store data locally. The data is organized into a name/value relationship and uses the standard XML format. Apple recommends that the decision as to when to use property lists to persist data should be limited to small amounts, preferably less than a few hundred kilobytes. For larger amounts, Apple offers Core Data as an alternative solution.

Property lists are used quite frequently in standard Apple applications. For example, the application’s user settings are stored in a property list. The Settings app requires a specific format, but the structure is a property list.

Property List Types

To convert the XML element values in a property list into an Objective C object, Apple has defined the following relationships between the Objective C object and the property list’s XML element value, as shown in Table 22-1.

Table 22-1: Property List Types

Data Type XML Tag iOS Class
array < array> NSArray
dictionary < dictionary> NSDictionary
string < string> NSString
data < data> NSData
date < date> NSDate
integer < integer> NSNumber (intValue)
floating point <real> NSNumber (floatValue)
Boolean <true/> or <false/> NSNumber (boolValue) YES or NO

Creating Property Lists

You can create property lists in two ways:

  • Programmatically
  • Using the property list editor

Programmatically

You can create a property list programmatically directly in Objective-C if all of the objects derive from the NSDictionary, NSArray, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required