A9S6
A9S6

Reputation: 6675

Where are the application preference files location on Mac

I am having a hard time finding from where my application is picking up its window dock and location settings. I removed the related plist files and folders from the following directories:

  1. [USER]/Library/Preferences
  2. [USER]/Library/Preferences/By Host
  3. [USER]/Library/Caches
  4. [USER]/Library/Saved Application State

But the old window settings are retained when I launch the application. The application is using CFPreferencesCopyValue method to read preference values:

::CFPreferencesCopyValue("Toolbars:MyTools:Application", "kCFPreferencesCurrentApplication", kCFPreferencesCurrentUser, kCFPreferencesCurrentHost);

I am not very familiar with Mac's preferences mechanism. Can someone explain what could be happening here? Thanks

Upvotes: 2

Views: 7600

Answers (2)

Paul Jowett
Paul Jowett

Reputation: 6581

This problem hit me recently so I thought I'd post the answer here belatedly.

When you delete the preferences on a Mac (plist file) make sure you clear the cached preferences otherwise Java programs can keep working with the cached settings. You can:

  1. after you have deleted your plist file

  2. killall -u <your-user-name> cfprefsd

    OR

  3. reboot

Items 2. and 3. will cause the cache to be cleared and then your preferences will be reloaded as the cfprefsd restarts automatically.

I hope that helps.

Upvotes: 2

Volker
Volker

Reputation: 4660

The NSUserDefaults on Mavericks (at least) are cached and it is not recommended to edit the plist files manually. The actual files reside in a container folder (you may know this folder from sandboxing).

But you can use the command line utility defaultsto edit, change or delete preferences. To delete the defaults (= reset defaults for your app) you can run in terminal:

defaults delete com.myapp.* && rm -rf ~/Library/Preferences/com.myapp.*

This is taken from a blog entry that shows in detail explanations on user defaults and mavericks.

Upvotes: 1

Related Questions