• 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: NSUserDefaultsController, when does value change?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSUserDefaultsController, when does value change?


  • Subject: Re: NSUserDefaultsController, when does value change?
  • From: Matt Neuburg <email@hidden>
  • Date: Mon, 14 Jul 2008 09:34:48 -0700
  • Thread-topic: NSUserDefaultsController, when does value change?

On Sun, 13 Jul 2008 21:29:56 -0700, "James W. Walker" <email@hidden>
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.
m.

--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



_______________________________________________

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

  • Follow-Ups:
    • Re: NSUserDefaultsController, when does value change?
      • From: "James W. Walker" <email@hidden>
  • Prev by Date: [PDFDocument documentRef] internal method questions.
  • Next by Date: How to detect NSTextAttachment deletion
  • Previous by thread: NSUserDefaultsController, when does value change?
  • Next by thread: Re: NSUserDefaultsController, when does value change?
  • Index(es):
    • Date
    • Thread