Where to store music? - ios

I'm developing an application that downloads music from the web. I now need to upload it to the app store. But I don't know what folder I should save loaded music in. It says that for files downloaded from the Web, I need to use Library/Caches directory, but iOS can remove files from this directory. I don't want that to happen.

Store them either in the Documents or the Library directory. (NSDocumentsDirectory and NSLibraryDirectory constants, respectively.) iOS doesn't remove the files stored in there, as these are not temporary (tmp or Caches) paths.

Related

iOS Files App Registration with file types

I store video files in the Documents folder of my app. I need to present an option that enables users to copy video files from Documents folder to iOS Files app. I also want to automatically have a folder for my app in iOS files app (as seen in the screenshot).
I tried registering Document type "public.movie" (screenshot 2) but didn't help.
Wondering how to achieve it.

Can I create a Documents directory in Xcode, and put files in it for my iOS app through the UI. If so, how?

I need to read/write a tiny amount of info for data persistence in an iOS app. I am using plists and understand that I can read, but not write to the bundle. If I create the plist files initially at development time, how can I place the plists in the "Documents" area of my app so that they are later writable?
Short answer: No.
As you say, an iOS app's bundle is not writable, but it is readable.
Further, an app's documents directory doesn't exist until the app is run (on the user's target device) for the first time. Thus, you can't build your app's documents directory at compile-time, nor can you submit an app to the app store with a prepopulated Documents directory. (It would be nice if Apple gave us the ability to provide a "seed" documents directory that got moved to the documents directory at first launch, but they do not provide that facility -- at least not that I'm aware of.)
What you can do is to create a sub-directory of your bundle that contains a set of files that you want to place in the app's documents directory.
On launch, check a "hasBeenInstalled" flag in UserDefaults. If it's true, do nothing. if it's false, use the file manager to copy files from your app's bundle into the app's documents directory, then write hasBeenInstalled=true to UserDefaults.

iOS: Include the resource(audio) files into the application folder of the app rather than adding into the bundle

Currently my resource(audio) files is included in the bundle. Due to this user is unable to delete the unwanted audio files to save the disk space on his phone. Please let me know how can I directly include the audio files into the Applications folder of app while submitting the build to AppStore and not in the bundle. Thereby user can delete the files which are not of his interest and re-download from the cloud backup hosted on S3 if needed.
The only way to accomplish this is to NOT have the audio files included in the initial app install.
Instead, your app could download the audio files from a hosting service... either download them all on first launch, or download each file as-needed.
You would then store the files on the device so they don't need to be downloaded again... and you could provide a UI to delete files the user no longer wants stored locally.

Which is permanent storage directory in iOS?

I need to store permanently (as far as app is not uninstalled from the device), the photos that are taken from camera roll and photo library into my app's bundle. Perviously i was storing those file in tmp folder, i read that the contents of tmp folder will be purged by iOS if it finds less memory for other app to run.. so my images were not getting displayed in my app after 3 or 4 days as IOS would have purged the content of tmp folder.
SO where do i need to Store these files? In Documents folder? is documents folder is permanent ?people say that you should not store huge amount of files in documents folder.. There is no limit for the photos that can be taken from my app. user may take 100 photos, 200photos, 500photos, or more than that.. its ok if user uninstall the application.. i will download all those photos in background once he login again. so what would you suggest for this problem? any kind of help is highly appreciated.
thanks
You put the files in the Documents folder, or if you can download them again from Internet, in the cache folder. If in Documents folder, you must mark the files with the attribute that prevents them from getting backed up to iCloud, or your app will be rejected.
Do that using this documentation:
https://developer.apple.com/library/ios/qa/qa1719/_index.html
These rules are enforced pretty vigorously by Apple and spelled out in:
https://developer.apple.com/icloud/documentation/data-storage/
(Requires iOS app developer login to view, I believe.)
What you are looking for here is SQLite. Using SQLite you can store your data and Images.
For storing the Images you can refer this link

retain program data in iOS app while updating and sync to iCloud

When a new upgrade is released and installed on iOS, which folders / files are left untouched by the upgrade process? There are several folders; Library, Caches, Preferences, Documents.
Normally Application Support Directory is not created by default. What happen to AS folder during upgrade?
I learn that all data in Documents folder will copy to iTunes or iCloud by default. Is that true?
If I create my own CoreData db to persist, where should I keep?
Your best bet is to read the first half (which pertained to iOS) of this document from Apple:
In my experience, I put Core Data db in Documents folder if the iTunes File Sharing feature was not enabled on your app. Otherwise create a folder in the Library folder called Application Support or anything name, etc. With iTunes File Sharing enabled, user can accidentally delete any files in the Documents folder.
During the upgrade, the contents of Library and Documents folder are retained.

Resources