• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Array of dictionaries + NSUserDefaultsController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Array of dictionaries + NSUserDefaultsController
      • From: Uli Zappe <email@hidden>
References: 
 >Array of dictionaries + NSUserDefaultsController (From: Brent Gulanowski <email@hidden>)
 >Re: Array of dictionaries + NSUserDefaultsController (From: Brent Gulanowski <email@hidden>)

  • Prev by Date: Re: How do you create a NSTabViewItem containing NSImageView programmatically? I almost got it...
  • Next by Date: Re: Toolbar Item Validation in a Panel
  • Previous by thread: Re: Array of dictionaries + NSUserDefaultsController
  • Next by thread: Re: Array of dictionaries + NSUserDefaultsController
  • Index(es):
    • Date
    • Thread