Search code examples
objective-cmacososx-mavericksosx-yosemite

Save file in OS X in a private folder like iOS documents folder


Does OS X have a place within the application to save files like how you save files to the documents folders in iOS. I have .plist files to save for my app but I only want to be able to access them form within the app. Don't want do have a folder in the users documents folder or anything.

Primarily an iOS guy so apologies if this is obvious.


Solution

  • I'm not exactly sure what you want here.

    To get a directory to store files in an out of the way location, you can use the Application Support directory (~/Library/Application Support/[APP_NAME]/).

    To get the name of this directory, you pass NSApplicationSupportDirectory to -URLsForDirectory:inDomains: (see: Managing Files and Directories).


    To prevent the user from reading a file, you can encrypt it (see: Encrypting and Hashing Data).