Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to save files in iPhone app? Library/ vs Application Support/, and subdirectory vs non-subdirectory

Tags:

xcode

ios

iphone

I want to save files of user settings of my iPhone app in ~/Library/ directory.
I don't want to use ~/Documents/ directory because I don't want users to see or modify the files in iTunes using the file sharing feature.

But there are 4 choices to save files in ~/Library/:

1. ~/Library/some-data.plist
This uses Library/ directory without creating a subdirectory in it.
(The API constant name is NSLibraryDirectory)

2. ~/Library/MyAppName/some-data.plist
This uses Library/ directory and a subdirectory which name is my app's name.

3. ~/Library/Application Support/some-data.plist
This uses Application Support/ directory without creating a subdirectory in it.
(The API constant name is NSApplicationSupportDirectory)

4. ~/Library/Application Support/MyAppName/some-data.plist
This uses Application Support/ directory and a subdirectory which name is my app's name.

Questions

What are the merits and demerits of the each path above?
And where do you save your app's data in Library/?

Should I use ~/Library/ or ~/Library/Application Support/?

Should I create a subdirectory or shouldn't I create it?
If I should create a subdirectory, is it a good practice to use my app's name for the subdirectory?
Or is there better names for the subdirectory?

like image 470
user_ Avatar asked Nov 01 '22 17:11

user_


1 Answers

From: File System Programming Guide

Put app-created support files in the Library/Application support/ directory. In general, this directory includes files that the app uses to run but that should remain hidden from the user. This directory can also include data files, configuration files, templates and modified versions of resources loaded from the app bundle.

like image 103
bleft Avatar answered Nov 15 '22 06:11

bleft