Previous | Chapter contents | Next | Book PDF
In the Yellow Box, A property list is a structured representation of object data. It can be in binary or ASCII (that is, textual) format. The primary value of a property list is that it can be stored as an external source and read by a program at run time. Suite definitions and terminology definitions are property lists that represent the scriptable properties, elements, commands, and special terms of an application. They are loaded by an application when it is launched.
When an application loads an ASCII property list, the items in the property list are converted into Yellow Box objects based on how they are structured. These objects include NSString, NSData, NSArray, and NSDictionary objects. NSArrays and NSDictionaries are collection objects and thus can contain NSStrings and NSDatas as well as nested NSArrays and NSDictionaries.
A property list uses punctuation (curly braces, equal signs, parentheses, quotation marks, commas, and semicolons) to define its structure. Although indentation has no affect on how items are interpreted, property lists are frequently indented to improve readability. To represent NSDictionaries (as are suite terminologies and suite terminologies), you must enclose the entire property list in curly braces:
{ // NSStrings, NSDatas, NSArrays, // and NSDictionaries represented here }
The remainder of this section discusses how NSStrings, NSArrays, and NSDictionaries are represented in property lists. Because NSData objects are rarely represented in property lists--and do not occur in suite definitions or terminology definitions--they are not discussed here.
You represent an NSString by enclosing a symbol in quotation marks, for example:
"NSDocument"
(Sometimes quotes are optional, but it is recommended that you always use them.) The elements of an array are frequently NSStrings. The left (key) side of a key/value assignment used to define an item in a dictionary must be an NSString; the right (value) side may be an NSString. For example:
"Type" = "NSTextStorage";
You represent an NSArray by enclosing a comma-divided list with parentheses:
("cha ", "ctxt", "font")NSArrays are usually on the right (value) side of NSDictionary key/value assignments:
"SynonymAppleEventCodes" = ("cha ", "ctxt", "font");
(As noted earlier, you must always represent dictionary keys as NSStrings.) The elements of a represented array can be NSStrings, NSDatas, NSDictionaries, or other NSArrays. For example:
"TopLevelArray" = ("x", ("a", "b", "c"), "y", {"z" = "hello"});
An item in an NSDictionary is a key/value pair represented as an assignment (that is, it uses an equals sign as a separator and terminates with a semicolon). For example:
"AppleEventCode" = "aevt";
The left side of the assignment is referred to as the "key"; the key must be an NSString. The right side of the assignment is known as the "value"; it can be any allowable property-list type. For example, it could be another NSDictionary, which can itself nest other NSDictionaries:
{ // top-level dictionary // other stuff... "NSTextStorage" = { "Superclass" = "NSCoreSuite.AbstractObject"; "Attributes" = { "foregroundColor" = { "Type" = "NSColor"; "AppleEventCode" = "colr"; }; // more other stuff... }
Previous | Chapter contents | Next | Book PDF