I hope to set the user defaults to
~/Library/Preference
under the folder name 'MyFolder', plist name is
com.mycompany.myapp.plist
Do I need to create the plist file and the folder by my开发者_开发问答self or the system create automatically?
Is there any tutorial?
You need to use the User Defaults System. The User Defaults classes (particularly NSUserDefaults
) manage the creation and location of the preferences file and allow you to easily read and write preferences data.
By default, the User Defaults system creates a preferences file with your app's bundle ID and the plist
extension under the ~/Library/Preferences
folder, however you should not rely on this behaviour. If you use the API you don't need to know the location of the file as it's not important.
You should never create or manage the preferences file directly, you should always use the API.
精彩评论