Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone SDK Xcode - How to get all the filenames in the documents dir

I want to get all the filenames in my application's documents folder, and place them in an NSMutableArray. Nothing more, nothing less.

like image 328
Aleksander Azizi Avatar asked Aug 15 '11 11:08

Aleksander Azizi


1 Answers

There is a convenient method in NSFileManager:

NSFileManager *fileManager = [[NSFileManager alloc] init];
NSArray *files = [fileManager contentsOfDirectoryAtPath:documentsDirectory 
                                                  error:nil];
...
[fileManager release];

As of ARC you can of course drop the release statement.

like image 113
Mundi Avatar answered Sep 29 '22 13:09

Mundi