hi all, just wondering how i go about implementing software preferences so that when an app loads it reads them etc.
is it possible to store this file in the application bundle rather than have it stored as a file somewhere else? or is it good practice to store it in the preferences folder?
as normal im a bit of a newbie to cocoa so any advice you can give really appreciated.
You definitely shouldn't try to store preferences in the application bundle, and often you can't anyway. For several reasons: First: Your application could be stored on a server, and could be used by multiple users. How do you keep their preferences apart? Second: Your application could be stored on a CD-ROM, on a read-only disk image, or on a write-protected memory stick. How do you store the preferences? Third: At some point you might want to sign your application, so users can be sure it is your application, and not a trojan that attacks their Mac. If you modify the application folder by storing preferences, that won't work. Last: You can have more than one user on a Macintosh. Again, how do you keep their preferences apart? And anyone but the system administrator would need to enter a password anyway to store things into the application bundle.
In Carbon, you would use the function "FSFindFolder" to find the proper location for the preferences folder - you can use it to find the preferences folder, document folder, music folder and dozens of other special folders without having to know their names, so your code will work on a French system as well, where the preferences folder might not be called "Preferences". In Cocoa, there are APIs specifically for preferences that will do the right thing anyway.