KrisG
KrisG

Reputation: 11

What is the default folder to save files within an app in iOS 8

I have an app that saves files in iOS 7 without a problem and I can find them on iPad. The path is: /var/mobile/Applications/"UDID"/Documents The same app in iOS 8 and I cannot save the files and/or find them if they are saved somewhere. It tries to save it to /private/var/Containers/Bundles/Application/"UDID"/Documents but then it tries to load the saved file from /private/var/Containers/Bundles/Application/"UDID" and I am unable to change directory to /private/var/Containers/Bundles/Application/"UDID"/Documents to find the file. Any insight?

Upvotes: 1

Views: 2895

Answers (1)

Caleb
Caleb

Reputation: 125037

You should read TN2406: Changes to App Containers in iOS 8, which tells us the following (emphasis added):

iOS 8 changes the locations of the standard directories used for storing user and app data (e.g. Documents, Library). While the locations of these directories have always been an implementation detail, some applications improperly assume that the Documents and Library directories reside in the same directory as the application's bundle. iOS 8 splits the data of an application from the application bundle. Code which attempts to derive the path to the Documents or Library directories will return an invalid path on iOS 8. Attempting to access this path will fail, and may terminate your app.

It also explains how to use NSFileManager to get the location of the Documents directory, essentially this:

NSURL *documentsDirectoryURL = [[[NSFileManager defaultManager]
                                 URLsForDirectory:NSDocumentDirectory
                                 inDomains:NSUserDomainMask]
                                lastObject];

Upvotes: 3

Related Questions