Re: Ghost value in NSUserDefaults
Re: Ghost value in NSUserDefaults
- Subject: Re: Ghost value in NSUserDefaults
- From: Kevin Ballard <email@hidden>
- Date: Sun, 9 Jan 2005 13:30:21 -0500
+[NSUserDefaults standardUserDefaults] gives you an NSUserDefaults
object with several domains pre-existing. The first domain, IIRC, are
keys passed in through the command-line arguments (if you call an app
via the command-line you can override defaults there). The second
domain is user internationalization settings and the like, such as the
language and country. The third domain is the preferences from the
application's prefs file. The fourth domain is the registration domain.
When you ask it for a value, it goes down the domains in order. So when
you ask it for COUNTRY_KEY it finds the result in the 2nd domain and
never even looks at the 4th (where you registered the empty values).
This is just off the top of my head, so I could have some details
wrong, but I believe that's how it works.
On Jan 9, 2005, at 8:47 AM, Stephan Burlot wrote:
I start my application and do:
#define COUNTRY_KEY @"Country"
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSDictionary *defaultValues = [NSDictionary
dictionaryWithObjectsAndKeys:
@"", SERVICE_KEY,
@"", COUNTRY_KEY,
@"", LANGUAGE_KEY,
@"", USERNAME_KEY,
@"", PASSWORD_KEY,
nil, ALERT_KEY,
@"No", MODE_KEY,
@"", DEFAULT_PAPERID_KEY,
@"", SERVICE_ID_FOR_PAPER_KEY,
nil];
[userDefaults registerDefaults:defaultValues];
NSLog(@"country: %@", [[NSUserDefaults standardUserDefaults]
objectForKey:COUNTRY_KEY]);
and I get:
country: CH
Where does this value comes from?
--
Kevin Ballard
email@hidden
http://www.tildesoft.com
http://kevin.sb.org
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden