Re: Bindings, User Defaults and the UI
Re: Bindings, User Defaults and the UI
- Subject: Re: Bindings, User Defaults and the UI
- From: Julian <email@hidden>
- Date: Wed, 28 Sep 2005 20:52:19 -0400
Hey Jeffery,
For the 5th checkbox just add an IBAction like so and wire it up:
- (IBAction)test:(id)sender {
[[[NSUserDefaultsController sharedUserDefaultsController] values]
setValue:THE_VALUE forKey:@"k1"];
[[[NSUserDefaultsController sharedUserDefaultsController] values]
setValue:THE_VALUE forKey:@"k2"];
[[[NSUserDefaultsController sharedUserDefaultsController] values]
setValue:THE_VALUE forKey:@"k3"];
[[[NSUserDefaultsController sharedUserDefaultsController] values]
setValue:THE_VALUE forKey:@"k4"];
}
With all 4 other bound keys and whatever THE_VALUE, prob [NSNumber
numberWithBool:YES || NO]
This will validate the items immediately and update the UI.
~Julian
On Sep 28, 2005, at 8:23 PM, Jeffrey E. Forcier wrote:
Greets all,
I'm attempting to set up a pseudo-prefpane utilizing an
NSUserDefaultsController and some checkboxes bound to its values.
However, when I set those values programmatically, the checkboxes
do not correctly update to reflect the change.
Four checkboxes are bound directly to user defaults values, and a
fifth checkbox reflects/sets the other four as a set. E.g. when the
other four are off, its state is NSOffState; all on, NSOnState;
some on and some off, NSMixedState. Clicking the fifth checkbox
directly sets or clears all of the other four at once (or should,
anyway).
The four checkboxes work fine on their own, as you'd expect. My
custom code to provide the fifth checkbox's behavior works with
regards to the reflection, as above (a method to update it is set
via target-action on the other four).
My problem is that when I click on the fifth checkbox, the code for
that--which sets all four values in the user defaults to true or
false, depending--sets the controller values fine, but the
checkboxes *do not reflect the changes*.
I found a note in the Cocoa Bindings docs describing this
situation, which said to use proper key-value encoding when setting
values programatically. At the time I had been using an
NSUserDefaults object in the code, so I figured that was the issue.
But updating all my code to use NSUserDefaultsController.values()
and its associated key-value compliant methods has not solved the
problem. Any ideas?
Apologies for the newbieness as usual,
Jeff
--
Jeffrey E. Forcier
Junior Developer, Research and Development
Stroz Friedberg, LLC
15 Maiden Lane, 12th Floor
New York, NY 10038
[main]212-981-6540 [direct]212-981-6546
http://www.strozllc.com
This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
right to
confidential or privileged treatment of this message is waived or lost
by any error in transmission. If you have received this message in
error, please immediately notify the sender by e-mail or by
telephone at
212.981.6540, delete the message and all copies from your system and
destroy any hard copies. You must not, directly or indirectly, use,
disclose, distribute, print or copy any part of this message if you
are
not the intended recipient.
_______________________________________________
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
~Julian
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