NSFileManager で取得したファイル名のリストを印刷するのに問題があります。ドキュメントには、文字列の配列を返すと書かれていますが、私の出力は空白です。以下のコード サンプルでは、実行によってコロンのみでインデックスが明らかになります。printfを誤用しているだけですか?ご協力いただきありがとうございます!
出力:
ファイルリストを印刷しようとしています -----------------------
ファイル数: 29
0: 1: 2: 3: 4: 5: 6: 7 : 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28:
- (IBAction)printFileList:(id)sender{
NSFileManager *fm = [[NSFileManager alloc] init];
NSString *path = @"/";
NSArray *files = [fm contentsOfDirectoryAtPath:path error:NULL];
printf("About to print file list ----------------------- \n");
int fileCount = [files count];
printf("Number of files: %d", fileCount);
for(int i = 0; i<fileCount; i++){
printf("%d: %s\n", i, [files objectAtIndex:i]);
}
}