2
<title>NSUserDefaults</title>
5
<a href ="NSUndoManager.html">[Previous] </a>
6
<a href ="Base.html">[Up] </a>
7
<a href ="NSValue.html">[Next] </a>
8
<h1>NSUserDefaults</h1>
11
<dt><a href ="http://www.gnustep.org/developers/whoiswho.html">Richard Frith-Macdonald</a>
14
<p>Version: $Revision: 1.17 $</p>
15
<p>Date: $Date: 2001/12/12 14:10:13 $</p>
16
<h2><a name ="cont-0">NSUserDefaults</a></h2>
17
<h2><a name ="NSUserDefaults">NSUserDefaults</a></h2>
18
<p><b>Declared in: </b> Foundation/NSUserDefaults.h</p>
19
<p><b>Inherits from: </b> NSObject</p>
20
<p><b>Conforms to: </b> NSObject
26
NSUserDefaults provides an interface to the defaults system,
27
which allows an application access to global and/or application
28
specific defualts set by the user. A particular instance of
29
NSUserDefaults, standardUserDefaults, is provided as a
30
convenience. Most of the information described below
31
pertains to the standardUserDefaults. It is unlikely
32
that you would want to instantiate your own userDefaults
33
object, since it would not be set up in the same way as the
39
Defaults are managed based on <em>domains</em>. Certain
40
domains, such as <code>NSGlobalDomain</code>, are
41
persistant. These domains have defaults that are stored
42
externally. Other domains are volitale. The defaults in
43
these domains remain in effect only during the existance of
44
the application and may in fact be different for
45
applications running at the same time. When asking for a
46
default value from standardUserDefaults, NSUserDefaults
47
looks through the various domains in a particular order.
51
<dt><code>NSArgumentDomain</code>
53
Contains defaults read from the arguments provided to
54
the application at startup. Volitile.
56
<dt>Application (name of the current process)
58
Application specific defaults, such as window positions. Persistant.
60
<dt><code>NSGlobalDomain</code>
62
Global defaults. Persistant.
64
<dt>Language (name based on users's language)
66
Constants that help with localization to the users's
69
<dt><code>NSRegistrationDomain</code>
71
Temporary defaults set up by the application. Volitile.
77
The <em>NSLanguages</em> default value is used to set up the
78
constants for localization. GNUstep will also look for the
79
<code>LANGUAGES</code> environment variable if it is not set
80
in the defaults system. If it exists, it consists of an
81
array of languages that the user prefers. At least one of
82
the languages should have a corresponding localization file
83
(typically located in the <file>Languages</file> directory
84
of the GNUstep resources).
89
As a special extension, on systems that support locales
90
(e.g. GNU/Linux and Solaris), GNUstep will use information
91
from the user specified locale, if the <em>NSLanguages</em>
92
default value is not found. Typically the locale is
93
specified in the environment with the <code>LANG</code>
98
<h2>Instance Variables </h2>
103
<li ><a href ="NSUserDefaults.html#method-0">+resetStandardUserDefaults</a>
104
<li ><a href ="NSUserDefaults.html#method-3">+setUserLanguages:</a>
105
<li ><a href ="NSUserDefaults.html#method-1">+standardUserDefaults</a>
106
<li ><a href ="NSUserDefaults.html#method-2">+userLanguages</a>
107
<li ><a href ="NSUserDefaults.html#method-4">-arrayForKey:</a>
108
<li ><a href ="NSUserDefaults.html#method-5">-boolForKey:</a>
109
<li ><a href ="NSUserDefaults.html#method-6">-dataForKey:</a>
110
<li ><a href ="NSUserDefaults.html#method-7">-dictionaryForKey:</a>
111
<li ><a href ="NSUserDefaults.html#method-8">-dictionaryRepresentation</a>
112
<li ><a href ="NSUserDefaults.html#method-9">-floatForKey:</a>
113
<li ><a href ="NSUserDefaults.html#method-10">-init</a>
114
<li ><a href ="NSUserDefaults.html#method-11">-initWithUser:</a>
115
<li ><a href ="NSUserDefaults.html#method-12">-integerForKey:</a>
116
<li ><a href ="NSUserDefaults.html#method-13">-objectForKey:</a>
117
<li ><a href ="NSUserDefaults.html#method-14">-persistentDomainForName:</a>
118
<li ><a href ="NSUserDefaults.html#method-15">-persistentDomainNames</a>
119
<li ><a href ="NSUserDefaults.html#method-16">-registerDefaults:</a>
120
<li ><a href ="NSUserDefaults.html#method-17">-removeObjectForKey:</a>
121
<li ><a href ="NSUserDefaults.html#method-18">-removePersistentDomainForName:</a>
122
<li ><a href ="NSUserDefaults.html#method-19">-removeVolatileDomainForName:</a>
123
<li ><a href ="NSUserDefaults.html#method-20">-searchList</a>
124
<li ><a href ="NSUserDefaults.html#method-21">-setBool:forKey:</a>
125
<li ><a href ="NSUserDefaults.html#method-22">-setFloat:forKey:</a>
126
<li ><a href ="NSUserDefaults.html#method-23">-setInteger:forKey:</a>
127
<li ><a href ="NSUserDefaults.html#method-24">-setObject:forKey:</a>
128
<li ><a href ="NSUserDefaults.html#method-25">-setPersistentDomain:forName:</a>
129
<li ><a href ="NSUserDefaults.html#method-26">-setSearchList:</a>
130
<li ><a href ="NSUserDefaults.html#method-27">-setVolatileDomain:forName:</a>
131
<li ><a href ="NSUserDefaults.html#method-28">-stringArrayForKey:</a>
132
<li ><a href ="NSUserDefaults.html#method-29">-stringForKey:</a>
133
<li ><a href ="NSUserDefaults.html#method-30">-synchronize</a>
134
<li ><a href ="NSUserDefaults.html#method-31">-volatileDomainForName:</a>
135
<li ><a href ="NSUserDefaults.html#method-32">-volatileDomainNames</a>
137
<hr><h2>Class Methods </h2>
138
<h3><a name ="method-0">resetStandardUserDefaults</a></h3>
139
+ (void) <b>resetStandardUserDefaults</b>;<br>
141
Resets the shared user defaults object to reflect the current
142
user ID. Needed by setuid processes whiich change the user they
146
<h3><a name ="method-1">standardUserDefaults</a></h3>
147
+ (NSUserDefaults*) <b>standardUserDefaults</b>;<br>
149
Returns a shared instance of the class containing the standard
150
defaults for the process.
153
<h3><a name ="method-2">userLanguages</a></h3>
154
+ (NSArray*) <b>userLanguages</b>;<br>
155
Standards: GNUstep NotMacOS-X NotOpenStep<br>
157
Returns the array of user languages preferences. Uses the
158
<em>NSLanguages</em> user default if available, otherwise
159
tries to infer setup from operating system information etc
160
(in particular, uses the <em>LANGUAGES</em> environment variable).
163
<h3><a name ="method-3">setUserLanguages:</a></h3>
164
+ (void) <b>setUserLanguages:</b> (NSArray*)languages;<br>
165
Standards: GNUstep NotMacOS-X NotOpenStep<br>
167
Sets the array of user languages preferences. Places the specified
168
array in the <em>NSLanguages</em> user default.
171
<hr><h2>Instances Methods </h2>
172
<h3><a name ="method-4">arrayForKey:</a></h3>
173
- (NSArray*) <b>arrayForKey:</b> (NSString*)defaultName;<br>
175
Looks up a value for a specified default, checks that it is
176
an array. Returns nil if it is not.
179
<h3><a name ="method-5">boolForKey:</a></h3>
180
- (BOOL) <b>boolForKey:</b> (NSString*)defaultName;<br>
182
Looks up a value for a specified default, checks that it is
183
a boolean. Returns NO if it is not present.
186
<h3><a name ="method-6">dataForKey:</a></h3>
187
- (NSData*) <b>dataForKey:</b> (NSString*)defaultName;<br>
189
Looks up a value for a specified default, checks that it is
190
an NSData object. Returns nil if it is not.
193
<h3><a name ="method-7">dictionaryForKey:</a></h3>
194
- (NSDictionary*) <b>dictionaryForKey:</b> (NSString*)defaultName;<br>
196
Looks up a value for a specified default, checks that it is
197
an NSDictionary object. Returns nil if it is not.
200
<h3><a name ="method-8">dictionaryRepresentation</a></h3>
201
- (NSDictionary*) <b>dictionaryRepresentation</b>;<br>
205
<h3><a name ="method-9">floatForKey:</a></h3>
206
- (float) <b>floatForKey:</b> (NSString*)defaultName;<br>
210
<h3><a name ="method-10">init</a></h3>
211
- (id) <b>init</b>;<br>
215
<h3><a name ="method-11">initWithUser:</a></h3>
216
- (id) <b>initWithUser:</b> (NSString*)username;<br>
220
<h3><a name ="method-12">integerForKey:</a></h3>
221
- (int) <b>integerForKey:</b> (NSString*)defaultName;<br>
225
<h3><a name ="method-13">objectForKey:</a></h3>
226
- (id) <b>objectForKey:</b> (NSString*)defaultName;<br>
230
<h3><a name ="method-14">persistentDomainForName:</a></h3>
231
- (NSDictionary*) <b>persistentDomainForName:</b> (NSString*)domainName;<br>
235
<h3><a name ="method-15">persistentDomainNames</a></h3>
236
- (NSArray*) <b>persistentDomainNames</b>;<br>
240
<h3><a name ="method-16">registerDefaults:</a></h3>
241
- (void) <b>registerDefaults:</b> (NSDictionary*)dictionary;<br>
245
<h3><a name ="method-17">removeObjectForKey:</a></h3>
246
- (void) <b>removeObjectForKey:</b> (NSString*)defaultName;<br>
250
<h3><a name ="method-18">removePersistentDomainForName:</a></h3>
251
- (void) <b>removePersistentDomainForName:</b> (NSString*)domainName;<br>
255
<h3><a name ="method-19">removeVolatileDomainForName:</a></h3>
256
- (void) <b>removeVolatileDomainForName:</b> (NSString*)domainName;<br>
260
<h3><a name ="method-20">searchList</a></h3>
261
- (NSArray*) <b>searchList</b>;<br>
265
<h3><a name ="method-21">setBool:forKey:</a></h3>
266
- (void) <b>setBool:</b> (BOOL)value <b>forKey:</b> (NSString*)defaultName;<br>
270
<h3><a name ="method-22">setFloat:forKey:</a></h3>
271
- (void) <b>setFloat:</b> (float)value <b>forKey:</b> (NSString*)defaultName;<br>
275
<h3><a name ="method-23">setInteger:forKey:</a></h3>
276
- (void) <b>setInteger:</b> (int)value <b>forKey:</b> (NSString*)defaultName;<br>
280
<h3><a name ="method-24">setObject:forKey:</a></h3>
281
- (void) <b>setObject:</b> (id)value <b>forKey:</b> (NSString*)defaultName;<br>
285
<h3><a name ="method-25">setPersistentDomain:forName:</a></h3>
286
- (void) <b>setPersistentDomain:</b> (NSDictionary*)domain <b>forName:</b> (NSString*)domainName;<br>
290
<h3><a name ="method-26">setSearchList:</a></h3>
291
- (void) <b>setSearchList:</b> (NSArray*)array;<br>
295
<h3><a name ="method-27">setVolatileDomain:forName:</a></h3>
296
- (void) <b>setVolatileDomain:</b> (NSDictionary*)domain <b>forName:</b> (NSString*)domainName;<br>
300
<h3><a name ="method-28">stringArrayForKey:</a></h3>
301
- (NSArray*) <b>stringArrayForKey:</b> (NSString*)defaultName;<br>
305
<h3><a name ="method-29">stringForKey:</a></h3>
306
- (NSString*) <b>stringForKey:</b> (NSString*)defaultName;<br>
310
<h3><a name ="method-30">synchronize</a></h3>
311
- (BOOL) <b>synchronize</b>;<br>
315
<h3><a name ="method-31">volatileDomainForName:</a></h3>
316
- (NSDictionary*) <b>volatileDomainForName:</b> (NSString*)domainName;<br>
320
<h3><a name ="method-32">volatileDomainNames</a></h3>
321
- (NSArray*) <b>volatileDomainNames</b>;<br>