问题
I want to get all the filenames in my application's documents
folder, and place them in an NSMutableArray
. Nothing more, nothing less.
回答1:
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.
来源:https://stackoverflow.com/questions/7064190/iphone-sdk-xcode-how-to-get-all-the-filenames-in-the-documents-dir