作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的应用程序中有一堆 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/
我的应用程序中有一堆 HTML 资源,按如下层次结构组织: dirA |---> index.html |---> a1.html |---> a2.html |---> dirB |--
我是一名优秀的程序员,十分优秀!