By default, all your user files and data will be saved in the document directory in your application. I have provided the sample code below to access the default document directory; plus a custom folder that you might call "MyFolderName" there
The end result is an array that has a list of NSString objects for files or directories in the path you specify.
//Accessing the default documents directory NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; //Appending the name of your custom folder, if you have any NSString *path = [documentsDirectory stringByAppendingPathComponent:@"MyFolderName"]; NSFileManager *fileManager = [NSFileManager defaultManager]; if ([fileManager fileExistsAtPath:path]) { // Directory exists NSArray *listOfFiles = [fileManager contentsOfDirectoryAtPath:path error:nil]; }
Hope this helps! :)
source share