I have set up the following code to save a file to the documents directory:
NSLog(@\"Saving File...\");
NSURLRequest *request = [NSURLRequest requestWithURL
I know this is an old question, but it's a good one and things have changed in iOS post Sandboxing.
The path to all the readable/writeable folders within the app will now have a hash in it and Apple reserves the right to change that path at any time. It will change on every app launch for sure.
You'll need to get the path to the folder you want and you can't hardcode it like we used to be able to do in the past.
You ask for the documents directory and in the return array, it's at position 0. Then from there, you use that value to supply to the NSFileManager to get the directory contents.
The code below works under iOS 7 and 8 to return an array of the contents within the documents directory. You may want to sort it according to your own preferences.
+ (NSArray *)dumpDocumentsDirectoryContents {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSError *error;
NSArray *directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsPath error:&error];
NSLog(@"%@", directoryContents);
return directoryContents;
}