是否有可能在文件夹及其所有子文件夹中搜索某种类型的所有文件(例如 mp4)?到目前为止,我可以使用以下代码一次为一个文件夹执行此操作:
NSFileManager *fm = [NSFileManager defaultManager];
NSArray *dirContents = [fm contentsOfDirectoryAtPath:cachesPath error:nil];
NSPredicate *fltr = [NSPredicate predicateWithFormat:@"self ENDSWITH '.mp4'"];
NSArray *filesWithAttr = [dirContents filteredArrayUsingPredicate:fltr];
NSLog(@"%@", filesWithAttr);
但是我的 Cashes 文件夹中有很多子文件夹。我是否必须逐一检查并检查 mp4 文件,还是有更简单的解决方案?
提前致谢