宏定義
#define FILEPATH [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
NSFileManager * fileManager = [NSFileManager defaultManager];
NSArray * tempFileList = [[NSArray alloc] initWithArray:[fileManager contentsOfDirectoryAtPath:FILEPATH error:nil]];
// NSLog(@"%@", tempFileList); 列印Documents檔案夾下的檔案
NSMutableArray *array = [NSMutableArray arrayWithCapacity:0];
for (int i = 0; i < tempFileList.count; i++) {
//周遊Documents目錄
if ([[tempFileList[i] pathExtension] isEqualToString:@"mp3"]) {
//取得字尾名這.MP3的檔案名
[array addObject:tempFileList[i]]; //存到數組
}
}