USING PROPERTY LISTS

In iOS programming, you can use property lists to store structured data using key/value pairs. Property lists are stored as XML files and are highly transportable across file systems and networks. For example, you might want to store a list of App Store application titles in your application. Because applications in the App Store are organized by category, it would be natural to store this information using a property list employing the structure shown in the following table:

CATEGORY TITLES
Games “Animal Park”, “Biology Quiz”, “Calculus Test”
Entertainment “Eye Balls - iBlower”, “iBell”, “iCards Birthday”
Utilities “Battery Monitor”, “iSystemlnfo”

In Xcode, you can create and add a property list to your project and populate it with items using the built-in Property List Editor. The property list is deployed together with the application. Programmatically, you can retrieve the values stored in a property list using the NSDictionary class. More importantly, if you need to make changes to a property list, you can write the changes to a file so that you can later refer to the file directly instead of the property list.

In the following Try It Out, you create a property list and populate it with some values. You then read the values from the property list during runtime, make some changes, and save the modified values to another property list file in the Documents folder.

NOTE To store application-specific settings that users can modify outside ...

Get Beginning iOS 5 Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.