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

后端 未结 3 1813
太阳男子
太阳男子 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:02

    Files usually go in ~/Library/Application Support/Your App/. Preferences go in ~/Library/Preferences/.

    0 讨论(0)
  • 2021-02-14 13:13

    NEVER modify a file inside your own app bundle.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题