Mac OS X: Where should I store common application data?

前端 未结 3 1254
一向
一向 2021-02-05 07:50

What\'s the standard path on MacOS X for storing application data that is to be shared by different users? I am not talking about temporary data, but data which is used by one p

相关标签:
3条回答
  • 2021-02-05 08:43

    I believe you're talking about Support files - a file that supports the application but is not required to run (your highscore table for example).

    These files should be put in ~/Library/Application Support/YourApp or /Library/Application Support/YourApp for shared users.

    The Library Directory Stores App-Specific Files

    0 讨论(0)
  • 2021-02-05 08:44

    Some applications put files into the /Users/Shared-directory. I know it's the standard way to share files between users, but I'm not 100% sure it's thought for application data storage.

    The there's the /Library*-folder which is thought for systemwide common data, similiar to the /Users/Usernames/Library.

    But you certainly shouldn't write data to the Application.app-directory. Users without admin rights won't even have the right to write to these directories.

    * = Or /System/Library. Need to verify.
    
    0 讨论(0)
  • 2021-02-05 08:50

    To get the directory, you can use the function "NSSearchPathForDirectoriesInDomains", with the directory parameter being "NSApplicationSupportDirectory", and the domainMask parameter being "NSLocalDomainMask".

    (NSApplicationSupportDirectory is the "Location of application support files", while NSLocalDomainMask means "Local to the current machine—the place to install items available to everyone on this machine.")

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