List saved files in iOS documents directory in a UITableView?

前端 未结 9 1683
予麋鹿
予麋鹿 2020-11-30 18:29

I have set up the following code to save a file to the documents directory:

NSLog(@\"Saving File...\");

NSURLRequest *request = [NSURLRequest requestWithURL         


        
9条回答
  •  春和景丽
    2020-11-30 19:27

    Here is the method I use to get the content of a directory.

    -(NSArray *)listFileAtPath:(NSString *)path
    {
        //-----> LIST ALL FILES <-----//
        NSLog(@"LISTING ALL FILES FOUND");
    
        int count;
    
        NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:NULL];
        for (count = 0; count < (int)[directoryContent count]; count++)
        {
            NSLog(@"File %d: %@", (count + 1), [directoryContent objectAtIndex:count]);
        }
        return directoryContent;
    }
    

提交回复
热议问题