开发者

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

开发者 https://www.devze.com 2022-12-15 12:34 出处:网络
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?Files usually go in ~/Library/Application Supp

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?


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


NEVER modify a file inside your own app bundle.


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.


Mac app data is now stored in ~/Library/Containers/YOUR-APP.

0

精彩评论

暂无评论...
验证码 换一张
取 消