Question

I have a background-only app that is controlled via a preference pane in the system preferences. To communicate between pref pane and app I use distributed notifications. User defaults are shared via [NSUserDefaults addSuiteNamed:]. This all works out very well.

The problem occurs when the user installs the pref pane "for all users", when prompted by the system preference pane. In this case prefs get written to ~/Library/Preferences/, same as when installed "for this user only". (I think this is the correct behavior.) However, when the prefpane reads a default key, the prefpane seems to be looking at /Library/Preferences/, not in the user's home directory.

To sum it up:

  • prefs pane installed in: ~/Library/PreferencePanes/
    • Defaults written to: ~/Library/Preferences/
    • Defaults read from: ~/Library/Preferences/
  • prefs pane installed in: /Library/PreferencePanes/
    • Defaults written to: ~/Library/Preferences/
    • Defaults read from: /Library/Preferences/

Could anyone shed some light as to where things go wrong?

Thanks, Kolja

Was it helpful?

Solution

You have essentially the same design as Growl. We use CFPreferences to read and write the user's preferences. See GrowlPreferencesController and the macros in GrowlDefinesInternal.h. The distributed notification cues both the background app and the prefpane to re-read the preferences.

(Don't take it quite as far as we do, though—it's fine to use NSNumber, NSDictionary, etc. with Core Foundation, and it's much easier to read.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top