[Previous] [Up] [Next]

NSUserDefaults

Authors

Richard Frith-Macdonald

Version: 0.1

Date: 28 February, 2000

NSUserDefaults

NSUserDefaults

Declared in: Foundation/NSUserDefaults.h

Inherits from: NSObject

Conforms to: NSObject


NSUserDefaults provides an interface to the defaults system, which allows an application access to global and/or application specific defualts set by the user. A particular instance of NSUserDefaults, standardUserDefaults, is provided as a convenience. Most of the information described below pertains to the standardUserDefaults. It is unlikely that you would want to instantiate your own userDefaults object, since it would not be set up in the same way as the standardUserDefaults.

Defaults are managed based on domains. Certain domains, such as NSGlobalDomain, are persistant. These domains have defaults that are stored externally. Other domains are volitale. The defaults in these domains remain in effect only during the existance of the application and may in fact be different for applications running at the same time. When asking for a default value from standardUserDefaults, NSUserDefaults looks through the various domains in a particular order.

NSArgumentDomain
Contains defaults read from the arguments provided to the application at startup. Volitile.
Application (name of the current process)
Application specific defaults, such as window positions. Persistant.
NSGlobalDomain
Global defaults. Persistant.
Language (name based on users's language)
Constants that help with localization to the users's language. Volitle
NSRegistrationDomain
Temporary defaults set up by the application. Volitile.

The Languages default value is used to set up the constants for localization. GNUstep will also look for the LANGUAGES environment variable if it is not set in the defaults system. If it exists, it consists of an array of languages that the user prefers. At least one of the languages should have a corresponding localization file (typically located in the Languages directory of the GNUstep resources).

As a special extension, on systems that support locales (e.g. GNU/Linux and Solaris), GNUstep will use information from the user specified locale, if the Languages default value is not found. Typically the locale is specified in the environment with the LANG environment variable.

Instance Variables

Methods


Class Methods

standardUserDefaults

+ (NSUserDefaults*) standardUserDefaults;


Instances Methods

arrayForKey:

- (NSArray*) arrayForKey: (NSString*)defaultName;

boolForKey:

- (BOOL) boolForKey: (NSString*)defaultName;

dataForKey:

- (NSData*) dataForKey: (NSString*)defaultName;

dictionaryForKey:

- (NSDictionary*) dictionaryForKey: (NSString*)defaultName;

dictionaryRepresentation

- (NSDictionary*) dictionaryRepresentation;

floatForKey:

- (float) floatForKey: (NSString*)defaultName;

init

- (id) init;

initWithUser:

- (id) initWithUser: (NSString*)username;

integerForKey:

- (int) integerForKey: (NSString*)defaultName;

objectForKey:

- (id) objectForKey: (NSString*)defaultName;

persistentDomainForName:

- (NSDictionary*) persistentDomainForName: (NSString*)domainName;

persistentDomainNames

- (NSArray*) persistentDomainNames;

registerDefaults:

- (void) registerDefaults: (NSDictionary*)dictionary;

removeObjectForKey:

- (void) removeObjectForKey: (NSString*)defaultName;

removePersistentDomainForName:

- (void) removePersistentDomainForName: (NSString*)domainName;

removeVolatileDomainForName:

- (void) removeVolatileDomainForName: (NSString*)domainName;

searchList

- (NSArray*) searchList;

setBool:forKey:

- (void) setBool: (BOOL)value forKey: (NSString*)defaultName;

setFloat:forKey:

- (void) setFloat: (float)value forKey: (NSString*)defaultName;

setInteger:forKey:

- (void) setInteger: (int)value forKey: (NSString*)defaultName;

setObject:forKey:

- (void) setObject: (id)value forKey: (NSString*)defaultName;

setPersistentDomain:forName:

- (void) setPersistentDomain: (NSDictionary*)domain forName: (NSString*)domainName;

setSearchList:

- (void) setSearchList: (NSArray*)array;

setVolatileDomain:forName:

- (void) setVolatileDomain: (NSDictionary*)domain forName: (NSString*)domainName;

stringArrayForKey:

- (NSArray*) stringArrayForKey: (NSString*)defaultName;

stringForKey:

- (NSString*) stringForKey: (NSString*)defaultName;

synchronize

- (BOOL) synchronize;

volatileDomainForName:

- (NSDictionary*) volatileDomainForName: (NSString*)domainName;

volatileDomainNames

- (NSArray*) volatileDomainNames;