List saved files in iOS documents directory in a UITableView?

前端 未结 9 1686
予麋鹿
予麋鹿 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:25

    -(NSArray *)findFiles:(NSString *)extension{
    
    NSMutableArray *matches = [[NSMutableArray alloc]init];
    NSFileManager *fManager = [NSFileManager defaultManager];
    NSString *item;
    NSArray *contents = [fManager contentsOfDirectoryAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] error:nil];
    
    // >>> this section here adds all files with the chosen extension to an array
    for (item in contents){
        if ([[item pathExtension] isEqualToString:extension]) {
            [matches addObject:item];
        }
    }
    return matches; }
    

    The example above is pretty self-explanatory. I hope it answers you second question.

提交回复
热议问题