views:

115

answers:

1

Hi all,

I have some audio files saved under the Documents directory. I just want to get those file names so that I can display them in a tableview. Right now I'm using

NSArray* files = [[NSFileManager defaultManager] 
                      contentsOfDirectoryAtPath:DOCUMENTS_FOLDER error:&err];

How can I extract just the file names into an array using that returned NSArray* files Object?

+1  A: 

Try -stringByDeletingPathExtension on each of the filenames.

Vincent Gable
Thanks. but how can I view the string value of the file names? I tried NSLog(@"%@", files[0]); but it returns "NSCFArray". Which property should I look to? something like files[0].filename?
Jinru
Try using <code>[files objectAtIndex:0]</code>, to get element 0 of <code>files</code>, since it's an <code>NSArray</code> not a C-style array.
Vincent Gable
Now I'm getting it. Thanks!
Jinru