On Jul 14, 2008, at 9:34 AM, Matt Neuburg wrote:

On Sun, 13 Jul 2008 21:29:56 -0700, "James W. Walker" <[EMAIL PROTECTED] >
said:
I have a preferences dialog that I'm using with an
NSUserDefaultsController instance, my first use of bindings, and it
works.  But I want to post a notification when a certain setting
changes.  In my method that shows the dialog, I record the old value
of the setting.  In my action method for the OK button, I send a save
message to the defaults controller  (the "applies immediately" option
is off), send a synchronize message to the NSUserDefaults, then check
the value of the setting and compare it to the old value.  But the
value has not changed!  It obviously gets changed at some point,
because the next time I bring up the dialog, the new value has is
there.  What am I missing?

What you're doing is unnecessarily complicated. Just use KVO to observe the
desired value within the standardUserDefaults. You get a notification
contining the old value and the new value. Welcome to the world of bindings.


I think I considered KVO, but I looked in the NSUserDefaults reference, and didn't see any indication that it conforms to NSKeyValueObserving. Does the "Conforms To" section of a class reference only list formal protocols, not informal protocols?

I still wish I understood why the default hadn't changed after the save and synchronize. But thanks for the suggestion of a slicker approach.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to