Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 3.1

REVIEW

plist Class 1.1.3

Issue: 3.1 (September/October 2004)
Author: Greg Fiumara
Article Description: No description available.
Article Length (in bytes): 4,277
Starting Page Number: 10
Article Number: 3107
Related Web Link(s):

http://maccrafters.com/

Full text of article...

Adding major features to an application can be a daunting task. However, in order to make an application more successful, programmers cannot overlook the hurdle of implementing a good preference layout and storage technique. Although most programmers achieve a desirable preference interface, few apply a proper storage medium. When newer versions of their software come out, these same programmers often have to rewrite their entire preference scheme. This should no longer be the case with the free plist class from MacCrafters.

A property list, better known as a plist, is a solution to managing preferences that Apple has encouraged since the original release of Mac OS X. Plists store preferences a hierarchical series of key/value pairs defined by XML.

Managing these lists could not be easier with MacCrafters' class, using an almost "plug and play" setup. To start, simply drag the two included classes into the project window. Then, initialize the plist class by using it to create a new preference file. If there is a default set of preferences for the project, plist class will automatically load them if it cannot find an existing preference file at startup.

MacCrafters' plist class uses a parent/child-like syntax for setting and retrieving preferences. It is very similar to handling folder items. This makes it easy for even a beginner to use. To retrieve a preference from a file, say a checkbox value, use a simple string of code such as:

checkbox.value=prefs.root.getBoolean("theCheckboxValue")

...where "theCheckboxValue" is a key and a Boolean value is the value. This class even handles many routine retrieval tasks for you. One case of this would be the getValue method, which always returns a string value no matter what the data type the value is. The plist class is even robust enough to store and retrieve arrays with simplicity one would expect from REALbasic.

Ease of use is not the only positive trait of this class. The author includes a full-featured example project complete with comments on sections of code other programmers would most likely need to change. This enables programmers to speed preference development by simply copying and pasting code from the example project to their own project. The classes also feature error handling for the plist syntax.

The plist class download comes with great documentation, which includes additional example code and a list of properties and methods. At some points, the documentation reads as if the author is speaking to the reader, going through a laundry list of "what if" scenarios. Although helpful if a programmer falls into one of the specific situations, the documentation can quickly become confusing and seem cluttered to a programmer looking for a small piece of information.

For a small application, a simple text preference file may seem like a perfect fit. However, over time, the application will outgrow its current preferences and demand an improved design. With the simplicity and power of MacCrafters' plist class, no programmer should ever overlook the influence of preference files again.

End of article.