Reading and Writing Preferences

There are three ways in which to read and write information in the defaults database:

  • With the Property List Editor (/Developer/Applications/Utilities) installed as part of the Xcode Tools

  • From the command line using the defaults command-line utility

  • Converting the file to XML format using plutil and then using TextEdit (found in /Applications/Utilities) or another plain-text editor to modify the file by hand

Property List Editor

The Property List Editor, shown in Figure 14-2, is a GUI application installed with the Xcode Tools that lets you view and edit property list files. When you first open a property list with the Property List Editor, you’ll notice that the top root element is

The Language section of the International Preference panel

Figure 14-1. The Language section of the International Preference panel

collapsed. Click the disclosure triangle next to it, and you can drill through the various preferences.

As shown in Figure 14-2, there are three columns to the Property List Editor. These are:

Property List

Lists the keys of the property list; that is, the contents of the <key/> tags of a plist XML file.

Class

Lists the classes available for each key definition. This affects the value tags in the XML file as defined in Figure 14-1.

Value

Contains the value for the preference key.

The Property List Editor application

Figure 14-2. The Property List ...

Get Running Mac OS X Tiger 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.