Re: Binding to NSUserDefaults
Re: Binding to NSUserDefaults
- Subject: Re: Binding to NSUserDefaults
- From: Seth Willits <email@hidden>
- Date: Sun, 17 Mar 2013 16:00:13 -0700
On Mar 17, 2013, at 11:31 AM, Ken Thomases wrote:
>> In nibs we bind to NSUserDefaults through NSUserDefaultsController, but is there any point in using NSUserDefaultsController when binding to a default through code? (Or using KVO, also.) It's always seemed to work monitoring NSUserDefaults directly.
>
> Yes, you should bind through NSUserDefaultsController, regardless. Bindings established in IB are not significantly different from bindings established in code.
>
> NSUserDefaults is not KVO-compliant. It may work to fetch the value on a one-time basis (i.e. KVC), but you're not guaranteed to be informed when a default changes.
Question is, when does it not work? I've yet to see it fail. Maybe if I called registerDefaults: it wouldn't propagate notifications for that, but it seems fine in ever other case. (I've actually been using it for ages, though I do a mixture of using NSUDC and NSUD. I think It's probably that all of my bindings go through NSUDC but observations are always straight on NSUD.)
--
Seth Willits
_______________________________________________
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