anthony
anthony

Reputation: 41118

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

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?

Upvotes: 11

Views: 1777

Answers (4)

samwize
samwize

Reputation: 27383

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

Upvotes: 1

Chuck
Chuck

Reputation: 237110

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.

Upvotes: 4

Nicolás
Nicolás

Reputation: 7533

NEVER modify a file inside your own app bundle.

Upvotes: 10

Chris Long
Chris Long

Reputation: 3084

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

Upvotes: 18

Related Questions