What location do OSX/Cocoa applications generally use to store data files?

后端 未结 3 1806
太阳男子
太阳男子 2021-02-14 12:39

Do they write/store them within the app bundle/package itself? Or some other canonical location? Or does there not seem to be any standard?

3条回答
  •  我在风中等你
    2021-02-14 13:20

    You should decidedly not write files into your app bundle at runtime. There's no guarantee that a user running your app will have permission to modify it. As Chris said, support files go in Application Support and preferences go in ~/Library/Preferences. To find the user's Application Support folder, you can use the NSSearchPathForDirectoriesInDomains() function. To write preference files, you can use the NSUserDefaults or CFPreferences APIs.

提交回复
热议问题