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

£可爱£侵袭症+ 提交于 2019-12-04 11:28:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!