Some stuff on the net seems to indicate that NSUserDefaults does support KVO. 
If 
it doesn't, how would NSUserDefaultsController accurately notify of all changes 
to NSUserDefaults? Or maybe one has to always access it 
through NSUserDefaultsController to get consistent notifications? In which 
case, 
it kind of seems pointless that they are two separate classes.



----- Original Message ----
From: Dave Keck <davek...@gmail.com>
To: Chris Idou <idou...@yahoo.com>
Cc: cocoa-dev@lists.apple.com
Sent: Sat, 23 October, 2010 10:48:01 PM
Subject: Re: Multiple instances of [NSUserDefaults standardUserDefaults]

> Well, I've got some code, which I presume used to work, which relies on
> observing a value in the user defaults. The observer isn't getting triggered, 
>so
> I am guessing it is because they are separate instances. Both should be on the
> main thread.

Are you observing an instance of NSUserDefaults or
NSUserDefaultsController? NSUD doesn't support KVO – perhaps that's
the problem?

Also, for testing at least, you might as well allocate your own
NSUserDefaultsController instance and stick it in an ivar. That way,
pointer comparison in -observeValueForKeyPath: should always work as
expected if different instances are indeed being returned by the
convenience constructor.




_______________________________________________

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 arch...@mail-archive.com

Reply via email to