• 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: Using ScreenSaverDefaults with NSUserDefaultsController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using ScreenSaverDefaults with NSUserDefaultsController


  • Subject: Re: Using ScreenSaverDefaults with NSUserDefaultsController
  • From: leenoori <email@hidden>
  • Date: Sat, 16 Dec 2006 17:27:09 +0100

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).


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Prev by Date: Re: NsTableView and the form view.
  • Next by Date: Re: Slider in menu (like System Volume)
  • Previous by thread: Re: Frameworks, again...
  • Next by thread: Core Data delete performance
  • Index(es):
    • Date
    • Thread