libs-base/Documentation/gsdoc/NSUserDefaults.html
CaS 3cb98ad576 Minor MacOS-X compatibility change
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11388 72102866-910b-0410-8b05-ffd578937521
2001-11-13 07:44:57 +00:00

327 lines
11 KiB
HTML

<html><head>
<title>NSUserDefaults</title>
</head>
<body>
<a href ="NSUndoManager.html">[Previous] </a>
<a href ="Base.html">[Up] </a>
<a href ="NSValue.html">[Next] </a>
<h1>NSUserDefaults</h1>
<h3>Authors </h3>
<dl>
<dt><a href ="http://www.gnustep.org/developers/whoiswho.html">Richard Frith-Macdonald</a>
<dd>
</dl>
<p>Version: $Revision$</p>
<p>Date: $Date$</p>
<h2><a name ="cont-0">NSUserDefaults</a></h2>
<h2><a name ="NSUserDefaults">NSUserDefaults</a></h2>
<p><b>Declared in: </b> Foundation/NSUserDefaults.h</p>
<p><b>Inherits from: </b> NSObject</p>
<p><b>Conforms to: </b> NSObject
</p>
<hr>
<p>
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.
</p>
<p>
Defaults are managed based on <em>domains</em>. Certain
domains, such as <code>NSGlobalDomain</code>, 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.
</p>
<dl>
<dt><code>NSArgumentDomain</code>
<dd>
Contains defaults read from the arguments provided to
the application at startup. Volitile.
<dt>Application (name of the current process)
<dd>
Application specific defaults, such as window positions. Persistant.
<dt><code>NSGlobalDomain</code>
<dd>
Global defaults. Persistant.
<dt>Language (name based on users's language)
<dd>
Constants that help with localization to the users's
language. Volitle
<dt><code>NSRegistrationDomain</code>
<dd>
Temporary defaults set up by the application. Volitile.
</dl>
<p>
The <em>NSLanguages</em> default value is used to set up the
constants for localization. GNUstep will also look for the
<code>LANGUAGES</code> 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 <file>Languages</file> directory
of the GNUstep resources).
</p>
<p>
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 <em>NSLanguages</em>
default value is not found. Typically the locale is
specified in the environment with the <code>LANG</code>
environment variable.
</p>
<h2>Instance Variables </h2>
<ul>
</ul>
<h2>Methods </h2>
<ul>
<li ><a href ="NSUserDefaults.html#method-0">+resetStandardUserDefaults</a>
<li ><a href ="NSUserDefaults.html#method-3">+setUserLanguages:</a>
<li ><a href ="NSUserDefaults.html#method-1">+standardUserDefaults</a>
<li ><a href ="NSUserDefaults.html#method-2">+userLanguages</a>
<li ><a href ="NSUserDefaults.html#method-4">-arrayForKey:</a>
<li ><a href ="NSUserDefaults.html#method-5">-boolForKey:</a>
<li ><a href ="NSUserDefaults.html#method-6">-dataForKey:</a>
<li ><a href ="NSUserDefaults.html#method-7">-dictionaryForKey:</a>
<li ><a href ="NSUserDefaults.html#method-8">-dictionaryRepresentation</a>
<li ><a href ="NSUserDefaults.html#method-9">-floatForKey:</a>
<li ><a href ="NSUserDefaults.html#method-10">-init</a>
<li ><a href ="NSUserDefaults.html#method-11">-initWithUser:</a>
<li ><a href ="NSUserDefaults.html#method-12">-integerForKey:</a>
<li ><a href ="NSUserDefaults.html#method-13">-objectForKey:</a>
<li ><a href ="NSUserDefaults.html#method-14">-persistentDomainForName:</a>
<li ><a href ="NSUserDefaults.html#method-15">-persistentDomainNames</a>
<li ><a href ="NSUserDefaults.html#method-16">-registerDefaults:</a>
<li ><a href ="NSUserDefaults.html#method-17">-removeObjectForKey:</a>
<li ><a href ="NSUserDefaults.html#method-18">-removePersistentDomainForName:</a>
<li ><a href ="NSUserDefaults.html#method-19">-removeVolatileDomainForName:</a>
<li ><a href ="NSUserDefaults.html#method-20">-searchList</a>
<li ><a href ="NSUserDefaults.html#method-21">-setBool:forKey:</a>
<li ><a href ="NSUserDefaults.html#method-22">-setFloat:forKey:</a>
<li ><a href ="NSUserDefaults.html#method-23">-setInteger:forKey:</a>
<li ><a href ="NSUserDefaults.html#method-24">-setObject:forKey:</a>
<li ><a href ="NSUserDefaults.html#method-25">-setPersistentDomain:forName:</a>
<li ><a href ="NSUserDefaults.html#method-26">-setSearchList:</a>
<li ><a href ="NSUserDefaults.html#method-27">-setVolatileDomain:forName:</a>
<li ><a href ="NSUserDefaults.html#method-28">-stringArrayForKey:</a>
<li ><a href ="NSUserDefaults.html#method-29">-stringForKey:</a>
<li ><a href ="NSUserDefaults.html#method-30">-synchronize</a>
<li ><a href ="NSUserDefaults.html#method-31">-volatileDomainForName:</a>
<li ><a href ="NSUserDefaults.html#method-32">-volatileDomainNames</a>
</ul>
<hr><h2>Class Methods </h2>
<h3><a name ="method-0">resetStandardUserDefaults</a></h3>
+ (void) <b>resetStandardUserDefaults</b>;<br>
Resets the shared user defaults object to reflect the current
user ID. Needed by setuid processes whiich change the user they
are running as.
<hr>
<h3><a name ="method-1">standardUserDefaults</a></h3>
+ (NSUserDefaults*) <b>standardUserDefaults</b>;<br>
Returns a shared instance of the class containing the standard
defaults for the process.
<hr>
<h3><a name ="method-2">userLanguages</a></h3>
+ (NSArray*) <b>userLanguages</b>;<br>
Standards: GNUstep NotMacOS-X NotOpenStep<br>
Returns the array of user languages preferences. Uses the
<em>NSLanguages</em> user default if available, otherwise
tries to infer setup from operating system information etc
(in particular, uses the <em>LANGUAGES</em> environment variable).
<hr>
<h3><a name ="method-3">setUserLanguages:</a></h3>
+ (void) <b>setUserLanguages:</b> (NSArray*)languages;<br>
Standards: GNUstep NotMacOS-X NotOpenStep<br>
Sets the array of user languages preferences. Places the specified
array in the <em>NSLanguages</em> user default.
<hr>
<hr><h2>Instances Methods </h2>
<h3><a name ="method-4">arrayForKey:</a></h3>
- (NSArray*) <b>arrayForKey:</b> (NSString*)defaultName;<br>
Looks up a value for a specified default, checks that it is
an array. Returns nil if it is not.
<hr>
<h3><a name ="method-5">boolForKey:</a></h3>
- (BOOL) <b>boolForKey:</b> (NSString*)defaultName;<br>
Looks up a value for a specified default, checks that it is
a boolean. Returns NO if it is not present.
<hr>
<h3><a name ="method-6">dataForKey:</a></h3>
- (NSData*) <b>dataForKey:</b> (NSString*)defaultName;<br>
Looks up a value for a specified default, checks that it is
an NSData object. Returns nil if it is not.
<hr>
<h3><a name ="method-7">dictionaryForKey:</a></h3>
- (NSDictionary*) <b>dictionaryForKey:</b> (NSString*)defaultName;<br>
Looks up a value for a specified default, checks that it is
an NSDictionary object. Returns nil if it is not.
<hr>
<h3><a name ="method-8">dictionaryRepresentation</a></h3>
- (NSDictionary*) <b>dictionaryRepresentation</b>;<br>
<hr>
<h3><a name ="method-9">floatForKey:</a></h3>
- (float) <b>floatForKey:</b> (NSString*)defaultName;<br>
<hr>
<h3><a name ="method-10">init</a></h3>
- (id) <b>init</b>;<br>
<hr>
<h3><a name ="method-11">initWithUser:</a></h3>
- (id) <b>initWithUser:</b> (NSString*)username;<br>
<hr>
<h3><a name ="method-12">integerForKey:</a></h3>
- (int) <b>integerForKey:</b> (NSString*)defaultName;<br>
<hr>
<h3><a name ="method-13">objectForKey:</a></h3>
- (id) <b>objectForKey:</b> (NSString*)defaultName;<br>
<hr>
<h3><a name ="method-14">persistentDomainForName:</a></h3>
- (NSDictionary*) <b>persistentDomainForName:</b> (NSString*)domainName;<br>
<hr>
<h3><a name ="method-15">persistentDomainNames</a></h3>
- (NSArray*) <b>persistentDomainNames</b>;<br>
<hr>
<h3><a name ="method-16">registerDefaults:</a></h3>
- (void) <b>registerDefaults:</b> (NSDictionary*)dictionary;<br>
<hr>
<h3><a name ="method-17">removeObjectForKey:</a></h3>
- (void) <b>removeObjectForKey:</b> (NSString*)defaultName;<br>
<hr>
<h3><a name ="method-18">removePersistentDomainForName:</a></h3>
- (void) <b>removePersistentDomainForName:</b> (NSString*)domainName;<br>
<hr>
<h3><a name ="method-19">removeVolatileDomainForName:</a></h3>
- (void) <b>removeVolatileDomainForName:</b> (NSString*)domainName;<br>
<hr>
<h3><a name ="method-20">searchList</a></h3>
- (NSArray*) <b>searchList</b>;<br>
<hr>
<h3><a name ="method-21">setBool:forKey:</a></h3>
- (void) <b>setBool:</b> (BOOL)value <b>forKey:</b> (NSString*)defaultName;<br>
<hr>
<h3><a name ="method-22">setFloat:forKey:</a></h3>
- (void) <b>setFloat:</b> (float)value <b>forKey:</b> (NSString*)defaultName;<br>
<hr>
<h3><a name ="method-23">setInteger:forKey:</a></h3>
- (void) <b>setInteger:</b> (int)value <b>forKey:</b> (NSString*)defaultName;<br>
<hr>
<h3><a name ="method-24">setObject:forKey:</a></h3>
- (void) <b>setObject:</b> (id)value <b>forKey:</b> (NSString*)defaultName;<br>
<hr>
<h3><a name ="method-25">setPersistentDomain:forName:</a></h3>
- (void) <b>setPersistentDomain:</b> (NSDictionary*)domain <b>forName:</b> (NSString*)domainName;<br>
<hr>
<h3><a name ="method-26">setSearchList:</a></h3>
- (void) <b>setSearchList:</b> (NSArray*)array;<br>
<hr>
<h3><a name ="method-27">setVolatileDomain:forName:</a></h3>
- (void) <b>setVolatileDomain:</b> (NSDictionary*)domain <b>forName:</b> (NSString*)domainName;<br>
<hr>
<h3><a name ="method-28">stringArrayForKey:</a></h3>
- (NSArray*) <b>stringArrayForKey:</b> (NSString*)defaultName;<br>
<hr>
<h3><a name ="method-29">stringForKey:</a></h3>
- (NSString*) <b>stringForKey:</b> (NSString*)defaultName;<br>
<hr>
<h3><a name ="method-30">synchronize</a></h3>
- (BOOL) <b>synchronize</b>;<br>
<hr>
<h3><a name ="method-31">volatileDomainForName:</a></h3>
- (NSDictionary*) <b>volatileDomainForName:</b> (NSString*)domainName;<br>
<hr>
<h3><a name ="method-32">volatileDomainNames</a></h3>
- (NSArray*) <b>volatileDomainNames</b>;<br>
<hr>
</body>
</html>