gpt4 book ai didi

iPhone 开发者 : Recurse all project resoureces and collect paths

转载 作者:行者123 更新时间:2023-12-03 17:44:57 25 4
gpt4 key购买 nike

我的应用程序中有一堆 HTML 资源,按如下层次结构组织:

dirA
|---> index.html
|---> a1.html
|---> a2.html
|---> dirB
|---> b1.html
|---> b2.html
|---> dirC
|---> c5.html
|---> c19.html

我试图收集所有 HTML 资源的绝对路径,无论深度如何,但似乎不知道如何收集。到目前为止我已经尝试过:

NSArray myPaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"html"inDirectory:nil];

这会返回一个空数组,因为我的项目根目录下没有 HTML 文件。然后是:

NSArray myPaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"html"inDirectory:@"dirA"];

这将返回一个仅包含 dirA 正下方的三个 HTML 资源的路径的数组。如果我正确地阅读了文档,我想这是可以预料的; pathsForResourcesOfType 不遍历子目录。但是有没有一种(最好是好的)方法可以做到这一点?

最佳答案

您可以使用NSDirectoryEnumerator迭代所有内容,然后只需检查字符串是否为 pathExtension是“html”。如果是,那么您已经找到了。

关于iPhone 开发者 : Recurse all project resoureces and collect paths,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2724750/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com