开发者

Create NSArray of a folder subpaths

开发者 https://www.devze.com 2023-04-10 18:51 出处:网络
Is there a core method to create开发者_C百科 an array representation of a folder? I mean something like

Is there a core method to create开发者_C百科 an array representation of a folder?

I mean something like

[
folder1[
    001.jpg,
    002.jpg
    ],
folder2[
    subfolder1[
        001.jpg
        002.jpg
        ],
    ]
folder3[
    001.jpg
    ]
]

I'm using subpathsAtPath to get an array of a single folder: should I loop across all subfolders or is there a smarter way?


NSArray* fileNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:&outError];


You may be better of with enumeratorAtPath:, you can then enumerate through decedents and use NSDirectoryEnumerator to get level.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号