Re: Array of dictionaries + NSUserDefaultsController
Re: Array of dictionaries + NSUserDefaultsController
- Subject: Re: Array of dictionaries + NSUserDefaultsController
- From: Uli Zappe <email@hidden>
- Date: Fri, 22 Oct 2004 04:34:38 +0200
Am 22.10.2004 um 02:42 schrieb M. Uli Kusterer:
At 17:37 Uhr -0400 21.10.2004, Brent Gulanowski wrote:
I figured it out.
If you turn off immediate saving with a -[NSUserDefaultsController
setSavesImmediately:] with a "NO" argument, the array members behave
like mutable dictionaries. This is a *very strange* side effect.
I could see how this would work:
If "immediate saving" is on, NSUserDefaultsController probably
directly writes to NSUserDefaults. NSUserDefaults is only defined to
return immutable objects. Sometimes it happens to return mutable ones,
but that's an implementation detail you can't rely on.
So, when you change something, it turns immutable, because next time
you access an item, it is re-fetched from NSUserDefaults.
OTOH, when "immediate saving" is off, it obviously means
NSUserDefaultsController has to keep a copy of the current values
until you've finished with them and they're saved. This copy will
obviously be in accordance with the settings you specified.
Ironically, though, it's exactly when you definitely get the data from
NSUserDefaults - at application startup - that NSUserDefaultsController
returns mutable objects consistently ...
Bye
Uli
________________________________________________________
Uli Zappe, Solmsstraße 5, D-65189 Wiesbaden, Germany
http://www.ritual.org
Fon: +49-700-ULIZAPPE
Fax: +49-700-ZAPPEFAX
________________________________________________________
_______________________________________________
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