I know this is an old question, but it's a good one, and everything has changed in iOS post Sandboxing.
The path to all readable / writable folders in the application will now have a hash, and Apple reserves the right to change this path at any time. It will change every time the application starts.
You will need to get the path to the folder you want, and you cannot hardcode it, as we used to do in the past.
You request the document catalog and the returned array, it is at position 0. Then from there you use this value to provide the NSFileManager to get the contents of the catalog.
Below is the code below in iOS 7 and 8 to return an array of content to the document directory. You can sort it according to your preference.
+ (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; }
Alex Zavatone Apr 16 '15 at 18:07 2015-04-16 18:07
source share