monsabre
monsabre

Reputation: 2099

how to set user defaults with folder name

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 myself or the system create automatically?

Is there any tutorial?

Upvotes: 1

Views: 147

Answers (1)

Rob Keniger
Rob Keniger

Reputation: 46030

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.

Upvotes: 1

Related Questions