Where do you save preferences?

Igor de Oliveira Couto igor at superstudent.net
Sat Jun 16 21:20:03 CDT 2012


Apologies in advance for the long post:

On 17/06/2012, at 10:20 AM, Richard Gaskin wrote:

[...]

> The OS X HIG clearly notes that files in the Preferences folder is for user-generated data.  As such, your app should never need to install anything there, but of course will need to write there at runtime when the user makes changes in your app's Preferences window.

A few weeks ago, someone else in this list pointed me to the following document:

http://developer.apple.com/library/mac/#documentation/FileManagement/Conceptual/FileSystemProgrammingGUide/FileSystemOverview/FileSystemOverview.html

If you have a look at "Table 1-3" on that page, it spells out how the "Preferences" and "Application Support" folders should be used in MacOS X. In regards to the Preferences folder, it states:

"This directory contains app-specific preference files. You should not create files in this directory yourself. Instead, use theNSUserDefaults class or CFPreferences API to get and set preference values for your app."

In regards to the Application Support folder, it states:

"Use this directory to store all app data files except those associated with the user’s documents. For example, you might use this directory to store app-created data files, configuration files, templates, or other fixed or modifiable resources that are managed by the app. An app might use this directory to store a modifiable copy of resources contained initially in the app’s bundle. A game might use this directory to store new levels purchased by the user and downloaded from a server.
All content in this directory should be placed in a custom subdirectory whose name is that of your app’s bundle identifier or your company."

I remember that there was some debate about the interpretation of the above, but it seemed to me that the consensus was that if you are creating your own preference file - instead of using the Cocoa classes and APIs directly - then you should be saving it inside a folder with your app's bundle name, inside "Application Support", and not in "Preferences".

The paragraphs above clearly seem to support that view. Note, in particular, where it states that the "Application Support" directory can be used to store a *modifiable* copy of a 'default' resource from the app's bundle - ie., a copy of the default prefs for the app, with user-modified settings. In contrast, the "Preferences" directory should *only* be used for storing files that are automatically created by the Cocoa framework, when it is used to store and retrieve app preferences using Cocoa's own APIs.

It would seem to me, then, that if we are storing our preferences created with LiveCode, and using our own file formats, we should not be accessing anything inside "Preferences", at any time, even if it IS user-generated data. Rather, Apple seems to be directing us to do everything inside "Application Support/MyAppBundleID".

That is the view that others presented to me, not long ago, and with which I tend to agree. I am not an expert on Apple's Human Interface Guidelines, however, and have not read their documentation extensively, so it is quite possible that there are further explanations elsewhere in their docs that may change this point of view. If anyone has any further info that may contradict this, please do let us know!

Many thanks in advance,

--
Igor de Oliveira Couto
Managing Director
Superstudent Headquarters
Suite 502, Level 5
491 Kent Street
Sydney NSW 2000
Australia
+61 (2) 9264 2642 | 9264 2646
igor at superstudent.net
http://www.superstudent.net




More information about the use-livecode mailing list