NSUserDefaultsController not updating defaults via binding
NSUserDefaultsController not updating defaults via binding
- Subject: NSUserDefaultsController not updating defaults via binding
- From: Luke Evans <email@hidden>
- Date: Fri, 16 Jan 2009 15:24:45 -0800
I tried a set up where some UI (slider) bound to a property on a
class, and separately this class' init programmatically set up a
binding to NSUserDefaultsController sharedUserDefaultsController to
initialise both the property and indirectly the slider control to
which it was also bound.
This worked great for initialisation. The property and slider were
indeed initialised to the value in the user defaults, and I could
change this externally and see the initial properly/slider value
change. However, I was expecting that this code (being a binding)
would also result in the user defaults being updated as the property
value changed (as a result of moving the slider or writing to the
property in another way). Unfortunately, this doesn't happen.
I've used NSUserDefaultsController many times in direct binding with
UI controls (like everyone else), and it works perfectly
bidirectionally with the simple binding. I have also used
programmatic binding to and observing of NSUserDefaultsController
sharedUserDefaultsController many times to listen to properties
changing in a one-way sense. This is the first time I have tried this
kind of configuration.
There's an easy work around - just use NSUserDefaults to read the
initial value, and to manually update the default when the property
changes - but the attraction of a binding was hard to resist. The
docs also seem to keep hinting "use NSUserDefaults as the primary
access - don't use NSUserDefaultsController for everything" (my
paraphrase), but the reasons behind this recommendation aren't spelled
out.
Has anyone had similar experiences? Is it unreasonable to expect this
kind of binding configuration to work?
-- Luke
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden