• 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: NSUserDefaultsController with defaults for another app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSUserDefaultsController with defaults for another app


  • Subject: Re: NSUserDefaultsController with defaults for another app
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 13 Aug 2008 00:09:23 -0500

On Aug 12, 2008, at 11:11 PM, Keith Alperin wrote:

My app ships as a System Preferences preference pane that contains a faceless agent app inside it's bundle. The agent app provides all of the functionality for my app. The prefpane stores preferences in the plist file for my app (rather than that for the host System Preferences app). I've been able to make this work by sending persistentDomainForName: to the shared instance of NSUserDefaults.

Now i'm trying to use bindings in order to simplify displaying a collection of dictionaries in an NSTable. I can see my preference data via an NSUserDefaultsController if i initialize it like this where defaultsController is actually an instance of NSObjectController:

NSUserDefaults *defaultsInstance = [NSUserDefaults standardUserDefaults];
[defaultsInstance addSuiteNamed:DOMAIN];
NSUserDefaultsController *controller = [[NSUserDefaultsController alloc] initWithDefaults: defaultsInstance initialValues: nil];
[defaultsController setContent:controller];


My NSTable shows the correct data, but when i update the information it is persisted back to the com.apple.systempreferences.plist file, and not the plist file for my app. Craig Hockenberry posted a similar question about 3.5 years ago (http://tinyurl.com/5upqnp) without receiving many responses and google has so far turned up very little.

Is there a way for me to bind my preferences to my view that's hosted in another app (in this case System Preferences?).

This page of the preference pane documentation says that NSUserDefaults isn't useful to preference panes, precisely because of the issues you're seeing:


http://developer.apple.com/documentation/UserExperience/Conceptual/PreferencePanes/Concepts/Managing.html#/ /apple_ref/doc/uid/20000703-BABHJCCA

Presumably, that extends to NSUserDefaultsController, too.

It shouldn't be too hard, though, to create a model object of your own which exposes your preferences as its properties. It would use the CFPreferences API as its backing store. There would be more work required to support all of the features of NSUserDefaultsController, though -- things like the deferred application of changes, reverting, restoring factory settings, etc.

Cheers,
Ken
_______________________________________________

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


References: 
 >NSUserDefaultsController with defaults for another app (From: Keith Alperin <email@hidden>)

  • Prev by Date: NSTokenField drag and drop
  • Next by Date: Re: Non-NSObject object and garbage collection
  • Previous by thread: NSUserDefaultsController with defaults for another app
  • Next by thread: NSTokenField drag and drop
  • Index(es):
    • Date
    • Thread