Personal Preferences
an example of a custom loadable preference bundle in 3.0

Greg Burd
8/24/92

What is this?
	This is an example of how you can create a dynamically loaded preference into Preferences.app.
	
When should I make a custom Preference?
	Most of the time your preferences for your application should be maintained in some panel accessed from the Info->Preferences menu item.  I know it is tempting to make a dozen or so of these preferences, but I personally don't want to see Preferences.app turn into a Mac Control Panel chaos scene, so control your self.  :-)
	On the other hand you should create one if what your program does is application independent, and it seems like the best place to maintain such information.  Don't do this if it would be cool, or make your product that much more interesting, do it because it is the correct place to put such information.  Remember that really you don't want to be going in and out of Preferences all day, that is not the objective.  Something that I would consider to put into a preference in the BackSpace setup info (anyone out there want to do this  :-)
	
How hard is it?
	Do you have an hour?  That is all it should take you to create a simple Preference.
	
Here are the steps involved:

1) Using ProjectBuilder create a new bundle project (if you don't know what bundles are, stop now and read the docs on NXBundle, then smile really big because they are really cool).

2) Copy the PersonalPreferences.[hm] files from this directory into your project directory and then add them to the project.  Rename those files to whatever you want to call your Preference. (Don't forget to rename the class info inside the files also!)

3) Do the same for the PersonalPreferences.nib section in the English.lproj directory.  That way you have a template to start from.  Rename that file to the same name that you used in the last step.

4) Create an icon for your preference, name it that same name again, and include it in the project.

5) Now rearrange the .nib in IB to suite your needs, and change the files owner to whatever your preference class is.  (Remember to do this you need to subclass Object, and then parse the file in IB.  Then select the files owner icon, and in the inspector change its class.)

6) Now rework the guts of the .hm files for your preference class.  The important things to do in your class are highlighted in my template files.  Basically you are subclassing a template class called Layout.h which is described in Preferences.h header file.

7) Time to compile!  When you get done debugging, rename the <foo>.bundle that you created to <foo>.preference.  Its file icon should change, watch your spelling.

8) To load it into Preferences, all you have to do is double click on it as if you were launching your new bundle.  Preferences should start up and load the object.  If there was an error it will let you know about it.  One final note, if you want your preference to load up for everyone at launch time of Preferences.app, copy the <foo>.preferences bundle your just created into Preferences.app's app wrapper.

Good Luck,

Greg Burd
NeXT Developer Support Team
¬