3

This may be related to this question but it did not help me much:

Where is a Mac Application's NSUserDefaults Data Stored?

When I quit my application my settings are written to the library/preferences folder and nowhere else. At least I don't see anything else. My application is also not sandboxed. Each time I run my app and change the setting a new settings file is written so I guess this is the real thing and not an old copy.

But if I edit the saved setting or even delete the file my application will start again with the settings it saved before. I even emptied the trash.

Where do these settings come from? I want to reset my application to the default settings I set in code but I am totally unable to do so. It always finds some setting to load.

Edit

I used code from this question: Easy way to see saved NSUserDefaults?

NSArray *path = NSSearchPathForDirectoriesInDomains(
NSLibraryDirectory, NSUserDomainMask, YES);
NSString *folder = [path objectAtIndex:0];
NSLog(@"Your NSUserDefaults are stored in this folder: %@/Preferences", folder);

It output says my settings are in library/Prefrences. So I deleted the file again. When I restart the application it still insists my settings are there.

Community
  • 1
  • 1
TalkingCode
  • 13,407
  • 27
  • 102
  • 147
  • the UserDefaults file is written automatically if not existing and filled with stuff like window positions and such.Yet, since there seem to be custom values inside, do you somehow initialize user defaults at stat up? – Volker Mar 02 '14 at 09:52

1 Answers1

0

Don't be tricked by the caching mechanism in OS X -
what you see in the file on disk isn't always the current value the app is seeing.

To get the current settings you should use the defaults command from the Terminal instead.
The docs can be found by typing man defaults or here.

Haven't tried it before myself but tye delete option sounds like what you're looking for..

Jay
  • 6,572
  • 3
  • 37
  • 65