Iphone ios查找所有保存的文件

Iphone ios查找所有保存的文件,iphone,ios,filepath,Iphone,Ios,Filepath,我的应用程序不时下载一些JPEG。所有jpeg文件名都以“hmof-*”格式保存。jpg有没有办法删除所有不以前缀“hmof-”开头的文件 很明显,我需要在循环中执行此操作,但我不确定要循环什么。类似这样的操作 NSString *bundleRoot = [[NSBundle mainBundle] bundlePath]; NSFileManager *fm = [NSFileManager defaultManager]; NSArray *dirContents

我的应用程序不时下载一些JPEG。所有jpeg文件名都以“hmof-*”格式保存。jpg有没有办法删除所有不以前缀“hmof-”开头的文件


很明显,我需要在循环中执行此操作,但我不确定要循环什么。

类似这样的操作

    NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];
    NSFileManager *fm = [NSFileManager defaultManager];
    NSArray *dirContents = [fm contentsOfDirectoryAtPath:bundleRoot error:nil];
    NSPredicate *fltr = [NSPredicate predicateWithFormat:@"NOT (self BEGINSWITH 'hmof-')"];
    NSArray *notHMOF = [dirContents filteredArrayUsingPredicate:fltr];
您可以使用以下方法删除文件:

for (int i=0; i<[notHMOF count]; i++) 
{       
    [fm removeItemAtPath:[NSString stringWithFormat:@"%@/%@",bundleRoot,[notHMOF objectAtIndex:i]] error:nil];
}

for(inti=0;i类似这样的东西

    NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];
    NSFileManager *fm = [NSFileManager defaultManager];
    NSArray *dirContents = [fm contentsOfDirectoryAtPath:bundleRoot error:nil];
    NSPredicate *fltr = [NSPredicate predicateWithFormat:@"NOT (self BEGINSWITH 'hmof-')"];
    NSArray *notHMOF = [dirContents filteredArrayUsingPredicate:fltr];
您可以使用以下方法删除文件:

for (int i=0; i<[notHMOF count]; i++) 
{       
    [fm removeItemAtPath:[NSString stringWithFormat:@"%@/%@",bundleRoot,[notHMOF objectAtIndex:i]] error:nil];
}

for(int i=0;i从什么?数组、集合、字典中删除它们?从什么?数组、集合、字典中删除它们?