Re: NSUserDefaultsController problems
Re: NSUserDefaultsController problems
- Subject: Re: NSUserDefaultsController problems
- From: Pierre Bernard <email@hidden>
- Date: Fri, 21 Apr 2006 20:32:51 +0200
Hi!
I have been tinkering about a similar set-up last night.
I believe the problem is that the values in the user defaults are immutable. I first tried writing a transformer to take the array of dictionaries and transform it into a mutable array of mutable dictionaries. This did not work as the array was never written back through the transformer back into the user defaults. I guess should have set up dependant keys so that the array would be considered modified when at least on of the child dictionaries is modified.
Around 1 AM I implemented a soltion that does indeed work. The transformer now returns an array of custom objects that act as proxy to the user defaults. The setter methods of this objects propagate changes to the defaults.
I am NOT PROUD of this ugly bit of code. But it does work.
I will ditch this implementaton in favor having the custom objects directly archived into user defaults.
Pierre
On Friday, April 21, 2006, at 07:58PM, Brian Stern <email@hidden> wrote:
>Howdy,
>
>I'm implementing a preferences window similar to the XCode prefs window.
>The prefs are bound to the shared NSUserDefaultsController. In one of the
>pref panels I have a setting that can only be set one time; after that
>changes in the UI aren't written out.
>
>The UI is essentially a master-detail UI. The master is a Popup menu
>showing a list of categories and the detail is a second Popup showing a
>property of the selected category. The data model for the categories is an
>NSArray containing an NSDictionary for each category. The dictionary
>contains strings for keys of category_name and property_name. The data
>model for the detail is a second NSArray containing NSDictionaries. Each
>dictionary contains a string for a key of detail_property_name.
>
>There is a category NSArrayController bound to NSUserDefaults and a
>property NSArrayController also bound to NSUserDefaults.
>
>The category Popup has content and contentValues bound to the category
>NSArrayController and selectedIndex is bound to selectionIndex in the
>category controller.
>
>The detail Popup has content and contentValues bound to
>arrangedObjects.detail_property_name in the property controller. It has
>selectedValue bound to selection.property_name in the category
>NSArrayController.
>
>Everything seems to display as expected: categories are shown in the master
>popup; the several properties are listed in the property popup; the
>selected property for a category is shown in the detail popup if I change
>the category.
>
>The problem is that I can only set the property for a given category one
>time. After app launch I can change the property in the property popup any
>number of times and the current selected property is written out to the app
>defaults file when I click save (which calls[[NSUserDefaultsController
>sharedUserDefaultsController] save:self];) After that any changes to the
>property popup have no effect on what is written out to the user defaults
>file until the app restarts. In fact notifications are sent when the popup
>is changed indicating that selection.property_name was changed but its
>value doesn't change.
>
>What could be the cause of this problem?
>
>--
>Brian Stern
>email@hidden
> _______________________________________________
>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
>
>
---
Spinning WebObjects or cooking up Cocoa in Switzerland?
Let me know: http://homepage.mac.com/I_love_my/
_______________________________________________
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