سؤال

I am working on Mac application,in which i have to store configuration information like current version of an application etc. I have go through some tutorials like this.

And I came to know that information is store in Preferences like com.apple.textedit.plist in ~/Library/Preferences.

But my question is when to store this basic information in .plist. ?!

هل كانت مفيدة؟

المحلول

Register user defaults (the default values for preferences) when your app starts up, for example, in the + (void)initialize method in your app delegate like this:

NSDictionary *appDefaults = [NSDictionary
                             dictionaryWithObjectsAndKeys:someObject, @"key",
                             nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];

When the user makes changes to the default values, those changes will be automatically saved to your app's .plist file in the Preferences folder. There should be no need to ever read or write directly to the preferences file. Check out the preferences programming guide.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top