How to list all folders and their subdirectories/files in iPhone SDK?

后端 未结 5 1398
野趣味
野趣味 2020-12-14 12:00

I want the user to select any file present in her/his iPhone so that it’s used as an e-mail attachment. For this purpose, I want to show the list of all files and folders pr

5条回答
  •  我在风中等你
    2020-12-14 13:02

    Here's the slowest(?) approach:

    NSFileManager * fileManager = [NSFileManager new];
    NSArray * subpaths = [fileManager subpathsAtPath:path];
    

    but that should at least point you to a more specialized implementation for your needs.

    Slightly lower level abstractions which allow you to enumerate on demand include NSDirectoryEnumerator and CFURLEnumerator. Depending on the depth of the directory, these have the potential to save much unnecessary interactions with the filesystem, compared to -[NSFileManager subpathsAtPath:].

提交回复
热议问题