Almost two years ago Craig Hockenberry wrote:
> I am working on a plug-in that uses ScreenSaverDefaults instead of
> NSUserDefaults (so it doesn’t put it's preferences in the
> application's
> domain.)
>
> I'd like to use bindings to manage these user defaults -- but for
> the life
> of me I can't figure out how to do it.
>
> I am loading an instance of NSUserDefaultsController from the NIB
> file --
> but don’t see anyway to get it to use something other than
> [NSUserDefaults
> standardUserDefaults].
>
> I've tried creating my own subclass and overriding the defaults:
> method to
> return an instance of ScreenSaverDefaults, but that doesn't seem to
> have any
> effect. (Interestingly, defaults: is invoked before awakeFromNib:
> so it
> seems we need an instance before the NIB is finished loading.)
>
> The only success I've had is by creating my own instance with
> [[NSUserDefaultsController alloc] initWithDefaults:myDefaults
> initialValues:myInitialValues]. But if I do this, I don’t have
> anything to
> bind against in Interface Builder -- and doing my own
> bind:toObject:withKeyPath:options defeats the purpose of using
> bindings in
> the first place.
>
> Any ideas or suggestions would be most appreciated. At this point
> my only
> option appears to be implementing an NSObjectController with my own
> preference model -- that's a whole lot of code I'd rather not write...
I'm wondering what the current state of the art is on this question.
My searches have only revealed questions, no answers:
http://forums.macnn.com/79/developer-center/189565/subclassing-
nsuserdefaultscontroller/
> You could use initWithDefaults:initialValues: and provide a
> subclass of NSUSerDefaults which uses a specific domain, but
> writing that NSUserDefaults subclass may well be as much work as
> writing your own replacement for NSUserDefaultsController.
Basically, is there any way to use NSUserDefaultsController in
loadable bundles (plug-ins, preference panes etc)? I'd like to keep
the preferences for loadable plug-ins separate from the main
application preferences because it's cleaner to keep things modular,
and because I've run into a weird NSUserDefaults behaviour which
makes it undesirable to do so (specifically, calling
"registerDefaults:" from a plug-in doesn't work).