Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Array of dictionaries + NSUserDefaultsController



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Array of dictionaries + NSUserDefaultsController (From: Brent Gulanowski <email@hidden>)
 >Re: Array of dictionaries + NSUserDefaultsController (From: Brent Gulanowski <email@hidden>)
 >Re: Array of dictionaries + NSUserDefaultsController (From: "M. Uli Kusterer" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.