Re: Array of dictionaries + NSUserDefaultsController
Re: Array of dictionaries + NSUserDefaultsController
- Subject: Re: Array of dictionaries + NSUserDefaultsController
- From: "M. Uli Kusterer" <email@hidden>
- Date: Fri, 22 Oct 2004 02:42:41 +0200
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.
I think what may help you lessen this effect somewhat could be if
you used the option to treat the entire array as one object.
NSArrayController at least has such an option which re-creates a new,
larger array with the objects in it and replaces the previous array
with that. That'd obviously avoid the whole problem of modifying an
immutable instance.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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