Mac OS X: preferences BASICS (1)

Source: Internet
Author: User
Directory:

0. Preparations

1. Introduction

2. preference file (plist file)

3. Example of editing a plist File

4. Application Instance

5. deep understanding of preference files

6. Common Tools

7. Problem Solving

 


Preparations:
    • Knowledge preparation:
      Familiar with the expression of directory layers in Mac OS X, that is, you can easily find the/library/preferences directory in the finder window.
    • Software preparation:
      Install property list EditorProgram. If not, you can find them in the following ways.
      1. In the random disc, the/Optional instils/xcode tools/In the first disc is available. Run xcodetools. mpkg, but it cannot be guaranteed to be the latest program.
      2. Propertylisteditor to download.csdn.net
        Download, address
      3. Apple official website download, see http://developer.apple.com/mac/, download here is certainly the latest program.

 


Introduction:

In Mac OS X, you click the Apple menu in the upper left corner, which contains an option called system preferences.
In other programs, such as safari and iPhoto, click the program name menu and you will see a similar menu option:
Preferences .... So what is preferences?


In fact, in general, it is a configuration (configuration file, Configuration
File ). For different programs and different operating systems, the configuration they support is stored on the system in different ways. For example, the BIOS of a PC is also a computer hardware configuration, which stores
In computer CMOS, the system uses registry to store system/user/application configuration information for familiar Windows systems,
For example, you can log on to the running program/desktop background and store all the files. the Windows registry is stored in multiple Binary-encrypted text files to store different systems/
User configuration information. in Mac OS X, a file format in text or binary XML format is used,
Generally, the file suffix is. plist, which is also called a plist file,
For example, the default homepage of browser Safari is stored in the homepage item in the com. Apple. safari. plist file.
Of course, the plist file is not just a configuration file in Mac OS X.


Common applications also have their own configuration files for storing default program parameters and data, as well as user-defined/changed parameters. Applications can use the mechanisms provided by the operating system, such as Windows
Registry and Mac OS
X plist, of course, application developers can use any other file format for storage based on their own needs or interests, such as ancient. ini text files.


In Mac OS
In system X, the support for plist files is in the text format at the beginning, so that users can open the editing with any text editing software. Later, for efficiency consideration
The binary format is introduced, which can improve the system reading speed. The plutil command line tool is introduced from this moment.
After the tiger system, the default plist files are in binary format.

 


Preference file (plist file ):

We know that most of the preference configurations are stored in the plist file, so let's look at the plist file.
The following content is the content of the simplest and most basic plist text file:

<? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype plist public "-// Apple // DTD plist 1.0 // en" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<Plist version = "1.0">
<Dict/>
</Plist>

It looks like in property list Editor:

 


Example of editing a plist file:
You can use the property list editor program mentioned above to edit a plist file. First, remember that the content of the plist file is composed of a series of attribute names and corresponding values in a certain order.
The following is a simple example. You can familiarize yourself with the tree structure and supported data types of plist files.


After running the property list editor program, you can see the content. There are three columns of empty tables under the button. The three columns are peroperty list,
Class, value. peroperty list indicates the attribute name list;
Class is the type that defines this attribute. The plist file supports multiple types, which are described later; value is the value of this attribute.

First, we need to create a root, click the New Root button, and the system generates an attribute named root, whose type is Dictionary (dictionary ), value is a non-editable row of "0 Key/value pairs" by default.


The new root button above the root is changed to new sibling,
But it is gray, that is, the plist file can only be one root, it has no brother. To add its sub-attributes under root,
There is a small triangle to the right on the left of the root, click it with the mouse, it turns into a downward triangle, that is, tell the program, then the new sibling button above becomes new
Child. I want to edit/view its sub-attributes. Therefore, for attributes that can be added to a subattribute, you must first open it to edit it. This will be used in the future.

First, create a simple attribute, click New child, and give it a name in the edge column, called background. Select string in the middle column, that is, a string type, write the value of this attribute on the rightmost side, for example ~ /Pictures/background.jpg.


Now the background is selected, and the above button is "new sibling". Click it and give it the childs attribute name,
Click the type column to display a list Of all supported types. Select the array type, that is, the array type. We all know that the array is a column composed of values of the same attribute, each value is 0,
1, 2... therefore, after you click the triangle on the left to open it, the system automatically sets a numeric attribute name for each subattribute,
We create two sub-attributes, each of which belongs to the string type. The values are son and daughter.
Select root and create a sub-attribute called country. The sub-attribute is dictionary. There are three sub-attributes, CA, CN, UN, and numerical values, the values are 0, 1, and 2 respectively.
Create a sub-attribute named mydata under root. The attribute is data and the content can be filled in by yourself. create another root sub-attribute, called today, with the property date. The program automatically fills in the date of the day.
Finally, create a sub-attribute named amitony as root. The sub-attribute is Boolean, that is, whether or not. The default value is yes.

After completing the above work, we get a plist file, for example.

If you are interested, you can save the plist file and open it in a text editor to see the structure in it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.