#import <DAPreferences.h>
The normal storage for preferences for screen-saver modules is in ~/Library/Preferences/ByHost, with the subsequent path hashed from machine-dependent data. This was not satisfactory to those who specified DownAndOut, as they wanted a quick way to deposit a DownAndOut configuration into any user's preference folder.
This class tracks a mutable-dictionary document, effectively duplicating the NSUserDefaults mechanism with the preferences in the dictionary, and the file in the assigned path. It knows when it's dirty, and can flush itself out to the file. It provides key accessors for the common data types.
Definition at line 32 of file DAPreferences.h.
Public Member Functions | |
| (id) | - initWithDictionary:forPath: |
| Designated initializer for a new preference file. | |
| (id) | - initWithPath: |
| Designated initializer for existing preference file, when there are no default values. | |
| (id) | - initWithDefaults: |
| Initialize the DownAndOut[tm] preferences with defaults. | |
| (void) | - flushToFile |
| Write the preference file if the contents have changed. | |
| (int) | - integerForKey: |
| Access integer value for a preference. | |
| (void) | - setInteger:forKey: |
| Set integer value for a preference. | |
| (id) | - objectForKey: |
| Access object value for a preference. | |
| (void) | - setObject:forKey: |
| Set object value for a preference. | |
| (BOOL) | - boolForKey: |
| Access BOOL value for a preference. | |
| (void) | - setBool:forKey: |
| Set Boolean value for a preference. | |
| (NSData *) | - dataForKey: |
| Access NSData stored under a key. | |
| (NSString *) | - stringForKey: |
| Access NSString stored under a key. | |
| (void) | - removeObjectForKey: |
| Remove a preference from the dictionary. | |
| (void) | - dealloc [implementation] |
| Unremarkable deallocator. | |
Protected Attributes | |
| NSMutableDictionary * | prefs |
| the preferences dictionary | |
| NSString * | path |
| path to preferences file | |
| BOOL | dirty |
| whether prefs have changed since last write. | |
|
|
Access BOOL value for a preference.
Definition at line 95 of file DAPreferences.m. References objectForKey:. |
|
|
Access NSData stored under a key. The inverse of this operation is setObject:forKey:
Definition at line 106 of file DAPreferences.m. References objectForKey:. |
|
|
Write the preference file if the contents have changed. This method writes the preferences dictionary to the designated preference file atomically, if any preference has changed since the last write. Definition at line 65 of file DAPreferences.m. |
|
|
Initialize the DownAndOut[tm] preferences with defaults. This method hard-codes a path to edu.uchicago.DownAndOut[tm].plist in the user's preferences folder. An attempt is made to read preferences from that file with initWithPath:. If that fails, that path and the given initial preferences are used in initWithDictionary:forPath:.
Definition at line 49 of file DAPreferences.m. References initWithPath:. |
|
||||||||||||
|
Designated initializer for a new preference file. Creates a DAPreferences ex nihilo, with preference state and a path to a file, which will be created or overwritten when the preferences are written. This method is for internal use only, as there it makes little sense to do this without more context.
Definition at line 29 of file DAPreferences.m. |
|
|
Designated initializer for existing preference file, when there are no default values.
The dictionary file at
Definition at line 37 of file DAPreferences.m. References dirty, path, and prefs. Referenced by initWithDefaults:. |
|
|
Access integer value for a preference.
Definition at line 73 of file DAPreferences.m. References objectForKey:. |
|
|
Access object value for a preference.
Definition at line 84 of file DAPreferences.m. References prefs. Referenced by boolForKey:, dataForKey:, integerForKey:, and stringForKey:. |
|
|
Remove a preference from the dictionary. Marks the preference dictionary dirty.
Definition at line 118 of file DAPreferences.m. |
|
||||||||||||
|
Set Boolean value for a preference. Marks the preference dictionary dirty.
Definition at line 101 of file DAPreferences.m. References setObject:forKey:. |
|
||||||||||||
|
Set integer value for a preference. Marks the preference dictionary dirty.
Definition at line 79 of file DAPreferences.m. References setObject:forKey:. |
|
||||||||||||
|
Set object value for a preference. Marks the preference dictionary dirty.
Definition at line 89 of file DAPreferences.m. Referenced by setBool:forKey:, and setInteger:forKey:. |
|
|
Access NSString stored under a key. The inverse of this operation is setObject:forKey:
Definition at line 112 of file DAPreferences.m. References objectForKey:. |
1.4.4