Property Lists

From GNUstepWiki

(Difference between revisions)
Revision as of 10:04, 7 July 2005
Comrade (Talk | contribs)
Sentence flow cleanups
← Previous diff
Current revision
Quineska (Talk | contribs)
Spelling errors, grammatical errors, removed TODO's
Line 3: Line 3:
== Introduction == == Introduction ==
-Property lists are used throughout GNUstep to store defaults, program settings, application meta information, and so on. MacOS X has begun to use XML based property lists, but GNUstep uses the classic property list format.(TODO: history of this style of property list). Support in GNUstep for XML property lists is still limited on some platforms; this situation should improve in the future as libxml platform build issues are resolved within GNUstep.+Property lists are used throughout GNUstep to store defaults, program settings, application meta information, and so on. MacOS X has begun to use XML based property lists, but GNUstep uses the classic property list format. Support in GNUstep for XML property lists is still limited on some platforms (namely Windows); this situation should improve in the future as libxml platform build issues are resolved within GNUstep.
-A property list is a logical tree of arrays, dictionaries, strings and numbers. The arrays and dictionaries may contain other arrays and dictionaries as data elements, and structures may become quite rich and expressive when representing complex data relationships. TODO: limits of embedding array/dictionaries inside each other.+A property list is a logical tree of arrays, dictionaries, strings and numbers. The arrays and dictionaries may contain other arrays and dictionaries as data elements, and structures may become quite rich and expressive when representing complex data relationships.
== Dictionary == == Dictionary ==
Line 19: Line 19:
} }
-As can be seen, each key-value pair is seperated by a semi-colon. Within the pair, the key is seperated from the value with an "equals" (=) sign. The key name is arbitrary, and not put in inverted commas (""). Shown above are: an unknown type (could be some sort of string - TODO), a string, an array, a number and another dictionary (respectively).+As can be seen, each key-value pair is separated by a semi-colon. Within the pair, the key is seperated from the value with an "equals" (=) sign. The key name is arbitrary, and not put in inverted commas (""). Shown above are: an unknown type (could be some sort of string - TODO), a string, an array, a number and another dictionary (respectively).
== Array == == Array ==
Line 34: Line 34:
) )
-Each value is seperated by commas. By the technical definition of an array, each value is of the same type (but I believe GNUstep permits different types TODO: check this).+Each value is seperated by commas. By the technical definition of an array, each value is of the same "type".
== Programming == == Programming ==
-GNUstep permits such property list files (normally having a .plist extension) to be loaded and subsequently used in your applications or tools. FoundationKit - in our case gnustep-base - classes NSDictionary and NSArray are used as representations of the property list data structures. Check the base API documentation for more information on working with these types programmatically.+GNUstep permits such property list files (normally having a .plist extension) to be loaded and subsequently used in your applications or tools. FoundationKit - in GNUstep's case gnustep-base - classes NSDictionary and NSArray are used as representations of the property list data structures. Check the base API documentation for more information on working with these types programmatically.
-NSString can be used to turn property lists in string form - either read from a file or constructed programmatically - to an equivalent data structure in memory. Again, see the API documentation for NSString (particularly the propertyList method).+NSString can be used to turn property lists in string form (either read from a file or constructed programmatically) into an equivalent data structure in memory. Again, see the API documentation for NSString (particularly the -propertyList method).
== Other tips == == Other tips ==
-* Property lists are much like C programming, where newlines and spaces and tabs are not so important to parsing.+* Property lists are much like C programming, where newlines and spaces and tabs are not so important to parsing, but syntax elements like braces, semilcolons and operators are.
* Some examples of property lists may include: * Some examples of property lists may include:
-** ~/GNUstep/System/Defaults/.GNUstepDefaults (this is your defaults file for software; be careful when editing)+** ~/GNUstep/System/Defaults/.GNUstepDefaults (this is your defaults file for all installed GNUstep software; be careful when editing this file manually)
[[Category:Development]] [[Category:Development]]

Current revision

NOTE: this document is still a work in progress. No responsibility is accepted for any problems arising from inaccuracies.

Contents

Introduction

Property lists are used throughout GNUstep to store defaults, program settings, application meta information, and so on. MacOS X has begun to use XML based property lists, but GNUstep uses the classic property list format. Support in GNUstep for XML property lists is still limited on some platforms (namely Windows); this situation should improve in the future as libxml platform build issues are resolved within GNUstep.

A property list is a logical tree of arrays, dictionaries, strings and numbers. The arrays and dictionaries may contain other arrays and dictionaries as data elements, and structures may become quite rich and expressive when representing complex data relationships.

Dictionary

A dictionary is a list of key-value pairs, where each item in the list has a name associated with it (key) and another type (value), which could be another dictionary, an array or often a string. It programmatically corresponds to NSDictionary/NSMutableDictionary. They take the following syntax:

{
   KeyName1 = Value1;
   AnotherKeyName = "Value2";
   Something = ( "ArrayItem1", "ArrayItem2", "ArrayItem3" );
   Key4 = 0.10;
   KeyFive = { Dictionary2Key1 = "Something"; AnotherKey = "Somethingelse"; };
}

As can be seen, each key-value pair is separated by a semi-colon. Within the pair, the key is seperated from the value with an "equals" (=) sign. The key name is arbitrary, and not put in inverted commas (""). Shown above are: an unknown type (could be some sort of string - TODO), a string, an array, a number and another dictionary (respectively).

Array

An array is a list of values, each of the same type (often arrays or dictionaries). Programmatically, it uses NSArray/NSMutableArray. It takes a syntax similar to the following:

( Value1, Value2, Value3, Value4 )
or
( Value1, Value2, Value3, Value4 )

Each value is seperated by commas. By the technical definition of an array, each value is of the same "type".

Programming

GNUstep permits such property list files (normally having a .plist extension) to be loaded and subsequently used in your applications or tools. FoundationKit - in GNUstep's case gnustep-base - classes NSDictionary and NSArray are used as representations of the property list data structures. Check the base API documentation for more information on working with these types programmatically.

NSString can be used to turn property lists in string form (either read from a file or constructed programmatically) into an equivalent data structure in memory. Again, see the API documentation for NSString (particularly the -propertyList method).

Other tips

  • Property lists are much like C programming, where newlines and spaces and tabs are not so important to parsing, but syntax elements like braces, semilcolons and operators are.
  • Some examples of property lists may include:
    • ~/GNUstep/System/Defaults/.GNUstepDefaults (this is your defaults file for all installed GNUstep software; be careful when editing this file manually)