Re: Multiple instances of [NSUserDefaults standardUserDefaults]
Re: Multiple instances of [NSUserDefaults standardUserDefaults]
- Subject: Re: Multiple instances of [NSUserDefaults standardUserDefaults]
- From: Chris Idou <email@hidden>
- Date: Sat, 23 Oct 2010 14:20:58 -0700 (PDT)
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 <email@hidden>
To: Chris Idou <email@hidden>
Cc: email@hidden
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 (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